Hi.
How can I isolate stuff inside a string so that two identical strings will match when they ought to? Sample code:
$str1 = " <TD class=xd01>3.04 (build 14)</TD>";
$str2 = "3.04 (build 14)";
if ($str1 !~ /$str2/) {
How can I isolate stuff inside a string so that two identical strings will match when they ought to? Sample code:
$str1 = " <TD class=xd01>3.04 (build 14)</TD>";
$str2 = "3.04 (build 14)";
if ($str1 !~ /$str2/) {
When you do this and have
characters that can have special meaning within the regex, then you need to surround with \Q and \E as in /\Q$str2\E/ which tells the regex that there should be no special
consideration as regex characters.
I ran your way and failed and then
placed the \Q and \E and came back with match. Just realize that
if you add an extra space anywhere it won't match either(so '3.04 (' is
not equal to '3.04 (' )
Wags ;)
print "no match?\n";
}
else {
print "match!\n";
}
The result this yields is "no match?", and not what I expect: "match!". I suspect the parentheses are responsible for this, so how can I rewrite the comparison to yield the result I need--and still work with other, more normal, strings?
Thanks!
Deane
*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************
_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
