I have a string, in PHP and the string has occurrences of the pattern %%abc%%(some substring)%%xyz%%
%%abc%%(some substring)%%xyz%%
There are multiple occurrences of such substrings withi
Use preg_replace_callback(), like this:
preg_replace_callback( '#%%abc%%(.*?)%%xyz%%#', function( $match) { // Do some logic (with $match) to determine what to replace it with return 'replacement'; }, $master_string);