So, I'm trying to create a function which does the following:
- Receive HTML in a string
- Find file paths (in SRC= attributes)
- Only replace image urls starting with the domain example.com
- Only replace images (jpg, jpeg, gif, png)
- Replace the domain of the image with example2.com
- Return HTML with image URLs replaced.
Is there an elegant way of doing that? I've been struggling to create a regular expression to take care of it me, and have only met with epic fail so far.
Any help greatly appreciated.