Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: regex to capture only lower case

by AnomalousMonk (Archbishop)
on Feb 13, 2015 at 21:50 UTC ( [id://1116670]=note: print w/replies, xml ) Need Help??


in reply to Reaped: regex to capture only lower case

/a-z.+\.txt/

If  /[a-z].+\.txt/ is the regex you're using (a bit difficult to tell because you don't use  <code> ... </code> tags), then it will match a string with a lower-case letter anywhere in it, followed by one or more of anything except a newline, followed by  '.txt' and then followed by anything. I recommend using string anchor assertions (untested):
    my @files = grep m{ \A [a-z] .* \.txt \z }xms, readdir $dh;
(which also allows for single-letter file names). Please see perlre, perlrequick, and perlretut.


Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

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

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

    No recent polls found