title: preg_replace how to replace only matching xxx($1)yyy pattern inside the selector
body: <p>I'm trying to use a regular expression to erase only the matching part of an string.  I'm using the <code>preg_replace</code> function and have tried to delete the matching text by putting parentheses around the matching portion. Example:</p>
  
  <pre><code>preg_replace('/text1(text2)text3/is','',$html);
  </code></pre>
  
  <p>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?</p>