Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

fourth digit should not match digit "2"

by Anonymous Monk
on Aug 06, 2012 at 16:14 UTC ( #985767=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to match $folder to M2000AAMFAD2015(match should fail if this digit is "2")7856(fourth digit can be anyother digit other than "2"),there will be digits after this,can somone tell me how can I do that?

if ($HMT =~m/A1234AHTLMR201[^2]\d+/) { }

Comment on fourth digit should not match digit "2"
Download Code
Re: fourth digit should not match digit "2"
by Corion (Pope) on Aug 06, 2012 at 16:17 UTC
Re: fourth digit should not match digit "2"
by CountZero (Bishop) on Aug 06, 2012 at 16:22 UTC
    m/\d{3}[013-9]\d{3}[013-9]/

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-09-19 20:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (146 votes), past polls