I'm looking to build a regular expression that will allow me to replace the periods (.) in a filename with an underscore (_).
Example: replace filename.doc with filename_doc
I've had a play around in Expresso, and have worked out that it will be something like .\w{3,4) - to pick up 3 or 4 character extentions eg doc, docx, xls, xlsx etc.
But I cannot figure out how to replace only the period and retain the extention.
You have to escape . sign. Try with following regex:
\.(\w{3,4})$
And replace it with:
_$1
$1 contains matched string in ()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With