Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Pattern mattching

by nobull (Friar)
on May 30, 2005 at 07:29 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-29 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found