Determine if a path matches a pattern I have been struggling with a regular expression involving path names.  Immediately, this is a bit troublesome, owing to the embedded / in the pattern,  but braces to the rescue.

First the convention I have imposed:

Every path in the set looks like:

/ifmxdev/files/file.0123


but that top directory can take a suffix, for example:

/ifmxdev_test/files/file.8765


The final suffix is exactly 4 digits

After much struggle and an hour of composing this plea, as well as my own thoughts, I came up with a truly ugly but working pattern:

$rawfile_pattern = qr{/ifmxdev[_0-9A-Za-z]*/files/file.\d{4}};
if (! $fname =~ $rawfile_pattern) {....


Now I'd just like some help in making that pattern more elegant, mainly compacting that bracketed section of the regex.
It probably doesn't matter, but the first element of that path can be ifmxdev______ or ifmxdev_x_x_x with that regex.

I suggest you use use the Unicode property alnum, which is [A-Za-z0-9] - \w without the underscore

qr{ \A /ifmxdev (?:_\p{alnum}+)? /files /file\.\d{4} \z }x