Slashdot question

http://stackoverflow.com/questions/13107078/how-can-we-filter-elements-in-array-with-regex-in-array-with-javascript

HTML

<a href="http://stackoverflow.com/questions/13107078/how-can-we-filter-elements-in-array-with-regex-in-array-with-javascript">how can we filter elements in array with regex in array with javascript</a>

JavaScript

function reduce (texts, re) {
      re = new RegExp (re.join ('|'));
      for (var r = [], t = texts.length; t--;)
        !re.test (texts[t]) && r.unshift (texts[t]);
      return r;
    }
                   
    alert (reduce (['the dog is hiding', 'cat', 'human', '1', '\$Steps\$\.xml'], ['rat', 'cat', 'dog', '[1-9]', '\$Steps\$\.xml']))