I'm also wondering why you are appending to $LookFor. If it is previously empty and you are using that as the pattern to match, that code should work. You probably don't want to append to it, just set it. Using qr// should help eliminate the escaping you've needed to do. And in that second regex, you can A) use \w which is a shortcut for the character class you've specified and B) eliminate the non-greedy matching as it doesn't help you because you've anchored your match anyway.
if ( $srch_host ) { $LookFor = qr/^$srch_host$/; } else { $LookFor = qr/^\w+$/; }
-sauoq "My two cents aren't worth a dime.";
In reply to Re: Regexp - exact matches
by sauoq
in thread Regexp - exact matches
by kingstonian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |