title: JS regex name highlighting
body: <p>I'm creating an auto complete and I'm having a little problem the results highlighting. You see my searching algorithm is very generous and ignores apostrophes in the result so therefore a query like <code>joes</code> will match <code>Joe's</code>. The search algorithm is taken care of and now comes the highlighting part. I wanted to make the matched pattern bold.</p>
  
  <p>Let's say I had an original unformatted result: <code>Joe’s</code> (<em>take note the rsquo \u2019)</em> and I wanted to highlight it like this: <code><strong>Joe’s</strong></code>, for the following queries <code>joes</code>, <code>joe's</code>, and <code>joe’s</code> <em>(rsquo \u2019)</em></p>
  
  <p>I included the right side single quotation mark in the query because you wouldn't know if someone was copying a query from a word document or something.</p>
  
  <p>I could easily do it by ignoring the fact that the quotation marks are there in both search/result strings but that would mess up the whole point of the search when you accidentally type something like <code>joes'</code> or even worse <code>jo'es</code>. So I somehow need to preserve the quote position. Also please take note that an apostrophe can also be anywhere in the unformatted result string like so <code>Suq'Ata</code>.</p>
  
  <p>Here are a list of scenarios:</p>
  
  <hr>
  
  <ul>
  <li>String: <code>Liliana's</code></li>
  <li>Queries: <code>lilianas</code>, <code>liliana's</code></li>
  <li>Result: <code><strong>Liliana's</strong></code></li>
  </ul>
  
  <hr>
  
  <ul>
  <li>String: <code>Suq'Ata</code></li>
  <li>Queries: <code>suqat</code>, <code>suq'at</code></li>
  <li>Result: <code><strong>Suq'At</strong>a</code></li>
  </ul>
  
  <hr>
  
  <ul>
  <li>String: <code>Telim'Tor's</code></li>
  <li>Queries: <code>telimt</code>, <code>telim't</code></li>
  <li>Result: <code><strong>Telim'T</strong>or's</code></li>
  </ul>
  
  <hr>
  
  <p>It should be noted that the position of the quotes in the query is important whereas when you misplace a quote in your query, it should not match at all. So it's either you have the correct quote position, or no quotes at all to highlight the original string.</p>
  
  <p>I actually don't mind if a proposed solution is to break apart each letter and loop through it (have thought about it) since I'll just be doing this to up to 5 strings at a given time. I'm looking forward to your suggestions!</p>