Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Pattern mattching

by nobull (Friar)
on May 30, 2005 at 07:29 UTC ( #461684=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://461684]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2023-09-23 20:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found