Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Removing characters in a file name

by haukex (Archbishop)
on Apr 23, 2020 at 20:01 UTC ( [id://11115972]=note: print w/replies, xml ) Need Help??


in reply to Re: Removing characters in a file name
in thread Removing characters in a file name

a sequence of digits surrounded by whitespace: /[A-Za-z0-9]+.*\b([0-9]+)\b/

No. That regex doesn't require whitespace anywhere.

The regex above thus excludes names that consist only of digits.

Since it's not anchored, it'll match anywhere in the filename, including its extension; only if you have files whose names are literally just digits, without an extension, it won't match. It'll also match two digits separated by a non-word (as well as non-whitespace) character.

WebPerl Regex Tester Link

Edit: Improved wording in second paragraph.

Log In?
Username:
Password:

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

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

    No recent polls found