I am using a converter that accepts Regex to do a mass "search and replace" in a database to change all .png to .jpg. Consider the following where a link to an image is mixed in with a lot of HTML code (simplified example):
bunch_of_text_http:// somewebsite.com/somepath/somefile.png_bunch_of_text
The "bunch_of_text" and "some-x" are all variables.
For clarification, the only .png's I need changed must follow a mostly prescribed URL. For example, I need to replace all .png's on the example.com domain but not on other domains. Here's another example:
Convert: http://example.com/images/XX/YY/filename.png to http://example.com/images/XX/YY/filename.jpg
WHERE
XX and YY are variables and may be at any level of depth in the folder structure.
But ignore any other domain other than example.com.
The code on the backend is written in PHP.
I need one line of Regex code to return only the ".png" text so my script can replace that with ".jpg". Any help is greatly appreciated.