Here's an example code snippet that uses regex to find and replace the specified URLs in all div
elements with a matching background-image or img
elements with a matching src URL:
index.tsx687 chars16 lines
Note that this code assumes that the URLs are enclosed in quotes and does not handle cases where the URLs are enclosed in single quotes, or the use of other syntaxes such as url('example.com/picture.png')
. In order to handle those cases, you will need to modify the regex appropriately.
gistlibby LogSnag