Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: regexp to check if file name matches pattern

by Marshall (Canon)
on Feb 24, 2009 at 23:22 UTC ( [id://746141]=note: print w/replies, xml ) Need Help??


in reply to regexp to check if file name matches pattern

An alternate solution (there are many):
$file= "SYSB_A31.GROUPINS%RDEBLIST%REAPPLY%2008.12.16.20.31.35.pdf"; if ($file =~ /^SYS[\w.]+%[\w.]+%[\w.]+%[0-9.]+.pdf/) {print "yes"} else {print "no"} #prints yes
A set of characters is enclosed in []. \w are the "word chars" and we add the "dot" to that set by \w.+. Same idea with 0-9.+. Other solution that has [^%]+ is good too. That means anything except %. Take your pick.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2026-05-13 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.