I'm trying to use a regular expression to erase only the matching part of an string. I'm using the preg_replace
function and have tried to delete the matching text by putting parentheses around the matching portion. Example:
preg_replace('/text1(text2)text3/is','',$html);
This replaces the entire string with '' though. I only want to erase text2, but leave text1 and text3 intact. How can I match and replace just the part of the string that matches?