title: Javascript if arrays contains string with regex
body: <p>I want to found if the variable <code>url</code> matches to any value of the array<br>
  <strong>For example, here's my array:</strong></p>
  
  <pre><code>var arr = ["test", "foo", "bar", "news-[0-999999999999999]*"];
  </code></pre>
  
  <p><strong>... and my string</strong></p>
  
  <pre><code>var url = "news-294";
  </code></pre>
  
  <p>I need to check for each <code>arr</code> value if it matches to url, with <code>regex</code></p>
  
  <p>So I've tried a <code>foreach</code> on the array, <code>new RegExp</code> for each value and then check if it matchs. But It didn't worked well, and It was leaking my browser memory (the <code>CPU</code> was at 24% for a blank page with the script)</p>
  
  <p>How can I do that? Thanks</p>
  
  <p><strong>EDIT: here's my code:</strong></p>
  
  <pre><code>var CMS = {
      RegexMatch: function(regex, str, callback) {
          while ((m = regex.exec(str)) !== null) {
              if(m[0] == str) callback();
          }
      },
      ArrayFindRegex: function(array, str, callback) {
          array.forEach(function(e) {
              CMS.RegexMatch(new RegExp(e), str, function() {
                  callback();
              });
          });
      },
          Check: function() {
                  var url = "blabla";
                  CMS.ArrayFindRegex(["test", "foo", "bar", "news-[0-999999999999999]*"], url, function() {
                      console.log('wow');
                  });
              }
          }
  }
  </code></pre>