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.