Categories
Troubleshooter

Search RegEx formulas to find and remove links or images

If you happen to ignore the secrets of regular expressions and you need to perform these rather common tasks, here is how you can do it.

A most useful search (and replace or remove) command is when you need to get rid of some links.

/<a href="http:\/\/domain\.com[^>]*>([\s\S]*?)<\/a>/

The formula above will find any domain.com link. If you need to remove the link and keep its reference unlinked, just use in the “replace” box the instruction $1

* Search for image tags

/<img([\s\S]*?)>/

* Search for images in a link to select both the image and the link

/<a href=[^>]*><img src="([\s\S]*?)><\/a>/

* Search for images with captions

/\[caption([\s\S]*?)\/caption]/
Exit mobile version