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

Re^2: Regex to detect file name

by Laurent_R (Canon)
on Jul 06, 2018 at 07:40 UTC ( [id://1218029]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex to detect file name
in thread Regex to detect file name

it is easy to do with two regexes, such as: ...
Easy, perhaps, but wrong. The suggested two regexes would match a string starting with an underscore.
DB<1> $f = "_foo"; DB<2> print "Success" if $f =~ /^[\w\.]+$/ && $f =~ /^\w/; Success DB<3>
Update (at 7:50 UTC): sorry, the last sentence below is wrong, I had missed the $ at the end of the first pattern.

It would also accept garbage characters in the middle.

Log In?
Username:
Password:

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

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

    No recent polls found