Regex isn't my strong point and I may be overcomplicating this but I've managed to come up with a pattern that appears to meets my needs.
\[img.*\].*photobucket.*(.jpg)\[\/img.*\]
Here's a demo:
https://regex101.com/r/fo98tP/6
I am wanting to replace the group match (i.e. ".jpg") with ".jpg~original".
I've figured out how to get the matches with preg_match_all but I haven't a clue how to make the substitution and inject it back into the original block of text.
To give some background, this is to try and workaround the new hotlinking policy and the intention is for my PHP script to go through all messages on my phpBB forum and do the search and replace above and then update the post if there's been a match/replacement. If it could be done directly in MySQL even better but I'm trying to walk before I can run!
Very much appreciate any help; my head hurts!