Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Removing characters in a file name

by Anonymous Monk
on Apr 23, 2020 at 18:21 UTC ( #11115965=note: print w/replies, xml ) Need Help??

in reply to Removing characters in a file name

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Removing characters in a file name
by haukex (Bishop) on Apr 23, 2020 at 20:01 UTC
    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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2021-05-07 11:22 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (91 votes). Check out past polls.