in reply to File name regex

I believe this will do what you ask, where if the option '_nnn' is present then the extension should be '.ilf', or if it is ' nnn' then the extension should be '.sht'; whilst capturing the entire optional part to $1 and the last digit of that optional part to $2:

Update: tightened slightly. Update2: Tightening removed; unnecessary.

m[ ^ \d{8} ( (?(?=.* \. ilf) _ | \s | (?!) ) ) (\d)+ )* \. (?:ilf| +sht) ]x

Whether you would call that a 'shortcut' is debatable.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.