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!

m/ / operator question 1

Status
Not open for further replies.

loosecannon1

Programmer
Feb 19, 2002
55
US
I need to match the entire PATTERN to the entire EXP

i.e. Since the following expression is not an exact match, besides case, I don't want it to return true

$var1 = "abcd"
$var2 = "abcdf"
$var1 =~ /$var2/i

Any ideas on how I can accomplish this?

 
loosecanon,

Try this
Code:
$var1 =~ /^$var2$/i # matches only if from beginning to end of string is a match.
Derek
 
Or, more efficient: (don't really need to whip out the regex engine for this kind of thing) -

if( lc($var1) eq lc($var2) ){

...

}

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top