Regex is the way to do these kind of things. Can be confusing for starters though. Try to look for regexbuddy (Win software) and a tutorial on Youtube. It's very powerful software.
No downvote, but this is rather questionable advice for two reasons:
The s/w you recommend is a USD40.00 item
Very loosely, PM is about helping folk learn how to help themselves (or to help them learn, period). IMO suggestions leading the OP to read the docs and search the site provide that in a global fashion far better than offering solutions requiring commercial s/w.