Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regex for last digit should not be "2"

by Anonymous Monk
on Aug 06, 2012 at 14:28 UTC ( #985738=note: print w/replies, xml ) Need Help??


in reply to Regex for last digit should not be "2"

Perhaps the simplest way is to test for a string that does not match (that is: !~) a regex like /2$/ ... which looks for the digit 2 anchored to the right-hand side of the string ... or maybe /2\s*$/ which would permit zero-or-more whitespace characters following the 2.

Go ahead ... use more than one test in that if-statement ... Look for a string that does match one regexp, and that does not match another.   As long as what you write works well and is abundantly clear, you are good to go.

  • Comment on Re: Regex for last digit should not be "2"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2016-09-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (472 votes). Check out past polls.