Let’s say I have a string contaning HTML markup with many img tags that look like this:
<img src="data/images/original/3.png" alt="" />
I need a regular expression that would change all images to have paths like this:
<img src="/utils/locate-image?path=data%2Fmedia%2Fimages%2Foriginal%2F3.png" alt="" />
I’m not very good with regular expression so I would appreciate some code example that can do this?
Don’t use regular expressions for this. The Simple HTML DOM parser should be perfect for the job.
It should be as easy as this: