This is a very small portion of a string i have scraped:
SEPVALAjazz(music)SEPVALC5.59SEPVALAlatin(music)SEPVALAcountry(music)SEPVALC6.70SEPVALArock(music)SEPVALC5.89SEPVALAdance(music)SEPVALAworld(music)SEPVALC6.70
I have manipulated the string with regex to insert the "SEPVALA" and "SEPVALC" values. I wish to remove the string between the patterns "SEPVALA" and "(music)SEPVALA" where ever it occurs in the text. In the above example this would remove "latin" and "dance".
The desired result would be:
SEPVALAjazz(music)SEPVALC5.59SEPVALAcountry(music)SEPVALC6.70SEPVALArock(music)SEPVALC5.89SEPVALAworld(music)SEPVALC6.70
The code i am implementing at the moment is:
$pattern="/SEPVALA(.+?)\(music\)SEPVALA/";
$replacement="SEPVALA";
$newstring=preg_replace($pattern, $replacement, $originalstring);
However this removes too much of the string as the regex engine picks up the very first "SEPVALA" and removes everything forward from this point until "(music)SEPVALA" (as it should do!) I need a method to scan backwards from "(music)SEPVALA" removing the offending text and stopping at the next "SEPVALA" before then moving forwards to the next match of "(music)SEPVALA" and so on. Or any other method to accomplish this. Many thanks.