Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Extracting datapart (YYYYMMDD) with filename regular expression

by Laurent_R (Canon)
on Dec 01, 2016 at 23:08 UTC ( [id://1177091]=note: print w/replies, xml ) Need Help??


in reply to Extracting datapart (YYYYMMDD) with filename regular expression

For the file names you've shown, a simple regex looking for 8 digits will do it:
/\d{8}/
Now, assuming you are not going to look for Apache logs dating from the twentieth century and that your program is likely to be obsolete in the 22nd century, you could narrow down the search:
/\b20\d{6}\b/
or narrow it down even further with something like this (untested):
/\b20[12]\d[01]\d[0123]\d\b/
(Of course, it is up to you to add capturing parentheses if you need.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found