Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot make this simple regexp work 1

Status
Not open for further replies.

whn

Programmer
Oct 14, 2007
265
US
My brain must be short circuited!!

Code:
$string = 'trunk.codeanalysis.test';
print "\$string = $string\n";

if ($string = m/trunk\.codeanalysis\.([a-z]+)/) {
  $suffix = $1; 
  print "Match - #$suffix#\n";
} else {
  print "No match!!\n";
}
exit 0;

A test run:
Code:
% ./test.pl
$string = trunk.codeanalysis.test
No match!!

How can it not find the match???

Please help to modify $string and keep the regexp so that a match is guaranteed.
[Note] I got this regexp from another place. I just want to construct a string to make "if ($string = m/trunk\.codeanalysis\.([a-z]+)/)" block work.

Thanks!
 
Hi

Code:
[b]if[/b] ($string =[COLOR=red yellow]~[/color] m/trunk\.codeanalysis\.([a-z]+)/)

Feherke.
feherke.ga
 
Holly! My brain is indeed short circuited!!!

Thank you, feherke!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top