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 (Archbishop) 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.