Regex for a file name without an extension – Stack Overflow
Posted by jpluimers on 2021/06/30
For me this unaccepted answer from [WayBack] Regex for a file name without an extension – Stack Overflow by [WayBack] Bohemian worked best:
Assuming the extensions are up to 4 chars in length (so filenames like
mr.smitharen’t considered as having an extension, butmr.smith.docandmr.smith.htmlare considered as having extensions):^.*[^.]{5}$No need to capture a group, as the whole expression is what you want – ie group 0.
Depending on the extension length, increase 5 to like 7 for 6 character extensions (it’s always N+1 when you want to match extensions of N characters).
--jeroen






Leave a comment