title: jQuery / Regex: How to compare string against several substrings
body: <p>I have a special validation need where <strong>I need to check if a string contains ANY out of several substrings</strong> like the following list:</p>
  
  <pre><code>12
  23
  34
  45
  56
  67
  78
  89
  90
  01
  </code></pre>
  
  <p>I am new to jQuery and the only thing I could think of here is the following which doesn't look good to me: </p>
  
  <pre><code>if(str.indexOf("12") &gt;= 0 || str.indexOf("23") &gt;= 0 || str.indexOf("34") &gt;= 0 || str.indexOf("45") &gt;= 0 || str.indexOf("56") &gt;= 0 || str.indexOf("67") &gt;= 0 || str.indexOf("78") &gt;= 0 || str.indexOf("89") &gt;= 0 || str.indexOf("90") &gt;= 0 || str.indexOf("01") &gt;= 0){
       // do stuff
  }
  </code></pre>
  
  <p><strong>Is there a better way</strong> where I can compare a string against multiple substrings, e.g. using Regex or arrays ?
  <strong>In addition, I would also need to count the number of matches for which I didn't find an approach.</strong> </p>
  
  <p>Many thanks in advance for any help with this. </p>