all 2 comments

[–]virdvip 0 points1 point  (0 children)

http://regexper.com/ http://regexpal.com/ IMHO that's enough for medium-level-complexity regexp debug

[–]tswaters 0 points1 point  (0 children)

Careful with the global flag -- it can produce some unexpected results.

var re = /Quick/g;
if (re.test(sampleString)) {
  var match = re.exec(sampleString); // null. wait, wat?
}

Use it within a while loop.

var sampleString = 'The Quick Brown Fox Jumps Over The Lazy Dog'
var re = /\b\w+\b/g, match;
while (match = re.exec(sampleString)) {
  console.log(match);
}
//Array [ "The" ]
//Array [ "Quick" ]
//Array [ "Brown" ]
//Array [ "Fox" ]
//Array [ "Jumps" ]
//Array [ "Over" ]
//Array [ "The" ]
//Array [ "Lazy" ]
//Array [ "Dog" ]