http://qs1969.pair.com?node_id=461684


in reply to Pattern mattching

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.)

Replies are listed 'Best First'.
Re^2: Pattern mattching
by tilly (Archbishop) on May 30, 2005 at 07:32 UTC
    Note that an Anonymous Monk cannot update his own posts. If it really bothers you, submit it to be edited. (I wouldn't suggest submitting it.)