title: Highlight search resuls with string part
body: <p>i am using the code below to highlight the search results:</p>
  
  <pre><code>$text = preg_replace("/\b($word)\b/i", '&lt;span class="highlight_word"&gt;\1&lt;/span&gt;', $text);
  </code></pre>
  
  <p>and its working fine.</p>
  
  <p>But the preg_replace return the whole string and highlight the words that match.</p>
  
  <p>I need to get a part of the string and only the whole string.</p>
  
  <p>A scenario is to get 100 chars before and 100 chars after the first match. Any help will be appreciated.</p>