Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Monks
conceptually, i'd like to match any value of string $str1 that starts (exactly) with another string ($str2), both stored in variables eg: Given: $str2 = ".1.2.3.4"; I'd like it to match if: $str1 =".1.2.3.4 lhkfjd"; but not if $str1 is any of "x1.2.3.4 lhkfjd"; " 1.2.3.4 lhkfjd"; "..1.2.3.4 lhkfjd"; etc Unfortunately, I can't seem to get the syntax quite correct, although i have looked at various perl regex tutorials, inc at perldoc. Solution with explanation deeply appreciated Cheers Chris In reply to Regex Start Anchor with variables by chrism01
|
|