CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Suggest any Regular Expression, Please

 



tallamohan
New User

Jul 22, 2012, 9:27 AM

Post #1 of 3 (4739 views)
Suggest any Regular Expression, Please Can't Post

$val1="abc";
$val2="xyz";
$val3="abcpqrxyz";


I want to compare val1 and val2 with val3 and
it should return the middle characters which is not common from both the strings....

ex: pqr


wickedxter
User

Aug 1, 2012, 2:26 PM

Post #2 of 3 (4474 views)
Re: [tallamohan] Suggest any Regular Expression, Please [In reply to] Can't Post


Code
 
my $var1 = 'abc';
my $var2 = 'xyz';
my $var3 = 'abcdexyz';

my @array = ($var1, $var2);
my @match = grep {$var3 =~ /$_/} @array;

print "This match was found $_" for @match;

This is what i came up with...


(This post was edited by wickedxter on Aug 1, 2012, 2:27 PM)


BillKSmith
Veteran

Aug 1, 2012, 2:47 PM

Post #3 of 3 (4470 views)
Re: [tallamohan] Suggest any Regular Expression, Please [In reply to] Can't Post

Is this what you mean?


Code
 my ($return) = $val3 =~ /$val1 (.*) $val2/x;

Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives