Skip to content

Instantly share code, notes, and snippets.

@lcaballero
Created September 4, 2015 00:53
Show Gist options
  • Save lcaballero/24086d53c3e4e7eb5d01 to your computer and use it in GitHub Desktop.
Save lcaballero/24086d53c3e4e7eb5d01 to your computer and use it in GitHub Desktop.
Find \num
matches = [
[ "abc", false ],
[ "a\\1d", true ]
]
re = /\\[0-9]/;
for (var i = 0; i < matches.length; i++) {
str = matches[i][0];
expected = matches[i][1];
val = re.test(str);
console.log("%s contains re %s (passes: %s)", str, val, val === expected);
}
@Fresheyeball
Copy link

Nice! Very clean. I like the way you use arrays as tuples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment