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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple regex issue

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
HI,

Why is the below expression never becomes TRUE ?
Looks like strings match to me ....

myfix2=patch_quark_gradient_fix;
key2=quark_gradient_fix;

if ($key2 =~ /$myfix2/i)



Long live king Moshiach !
 
For a match to occur [tt]$myfix2[/tt] needs to be in full within [tt]$key2[/tt]: this is very basic for regex usage.
I suggest that you deepen a bit your knowledge of regexes with some working examples taken from the documentation.
And if you want more help please clarify your goal (and also write correct code examples and include it between [tt][ignore]
Code:
[/ignore][/tt] tags).

Franco
: Online tools for structural design
: Magnetic brakes for fun rides
: Air bearing pads
 
Code:
$myfix2 =~ /$key2/i
is true because [tt]$myfix2[/tt] contains [tt]$key2[/tt]. [tt]$key2[/tt] does not contain [tt]$myfix2[/tt] so your expression is false.

Yours,

fish

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life was going to be spent in finding mistakes in my own programs.["]
--Maurice Wilkes, 1949
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top