title: JavaScript: indexOf vs. Match when Searching Strings?
body: <p>Readability aside, are there any discernable differences (performance perhaps) between using</p>
  <pre><code>str.indexOf(&quot;src&quot;) 
  </code></pre>
  <p>and</p>
  <pre><code>str.match(/src/)
  </code></pre>
  <p>I personally prefer <code>match</code> (and regexp) but colleagues seem to go the other way. We were wondering if it mattered ...?</p>
  <p>EDIT:</p>
  <p>I should have said at the outset that this is for functions that will be doing partial plain-string matching (to pick up identifiers in class attributes for JQuery) rather than full regexp searches with wildcards etc.</p>
  <pre><code>class='redBorder DisablesGuiClass-2345-2d73-83hf-8293' 
  </code></pre>
  <p>So it's the difference between:</p>
  <pre><code>string.indexOf('DisablesGuiClass-');
  </code></pre>
  <p>and</p>
  <pre><code>string.match(/DisablesGuiClass-/)
  </code></pre>