![]() |
|
No such thing as a small change | |
PerlMonks |
Re: Pattern mattchingby nobull (Friar) |
on May 30, 2005 at 07:29 UTC ( #461684=note: print w/replies, xml ) | Need Help?? |
What do you mean by "exactly" exactly?
Do you mean you only want a match if the pattern matches the whole string not just part of it? You do that by anchoring the pattern to the beginning and end /^\+\d\d\d\d\d\d$/. Note that the $ anchor actually permits a newline at the end of the string. If this bothers you then use \Z instead. As others have pointed out /^\+\d\d\d\d\d\d$/ is probably more tidy as /^\+\d{6}$/. (Oh, and BTW there was a spurious 's' in your OP - you should probably go update it.)
In Section
Seekers of Perl Wisdom
|
|