Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Regex pattern to find directories only with digits

by graff (Chancellor)
on Apr 12, 2013 at 03:03 UTC ( [id://1028263]=note: print w/replies, xml ) Need Help??


in reply to Regex pattern to find directories only with digits

If I were trying to get just the entries in my current working directory whose names consist entirely of digits, I'd do it like this:
my @digit_dirs = grep /^\d+$/, <*>; print join( "\n", @digit_dirs, "" );
If the entries of interest were in fact all "yyyymmdd" digit strings, I'd replace the "+" in the grep regex with {8}.

Replies are listed 'Best First'.
Re^2: Regex pattern to find directories only with digits
by Bindo (Acolyte) on Jun 20, 2013 at 10:19 UTC

    Thank you very much good people. I totally understood the concept. You all are the best. By the way if I get a satisfactory answer to a thread that I have started is there a way of closing/locking it? Cos I receive lot of reminders from root saying that I'd have to reply ...etc. Im just a beginner gentlemen so please let me know if there are any rules that I should follow. thanks

      If you are on unix or similar shell, use:
      ls|grep -P "^.*\d{8}.*"
      -P in grep is for using perl regex within shell grep.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found