title: PHP - How to modify matched pattern and replace
body: <p>I have string which contain space in its html tags</p>
  <p><code>$mystr = &quot;＆lt; h3＆gt; hello mom ？＆lt; / h3＆gt;&quot;</code></p>
  <p>so i wrote regex expression for it to detect the spaces in it</p>
  <p><code>$pattern = '/(?&lt;=&amp;lt;)\s\w+|\s\/\s\w+|\s\/(?=&amp;gt;)/mi';</code></p>
  <p>so next i want to modify the matches by removing space from it and replace it, so any idea how it can be done? so that i can fix my string like
  <code>&quot;＆lt;h3＆gt; hello mom ？＆lt;/h3＆gt;&quot;</code></p>
  <p>i know there is php function <code>pre_replace</code> but not sure how i can modify the matches</p>
  <p><code>$result = preg_replace( $pattern, $replace , $mystr );</code></p>