Skip to content

Instantly share code, notes, and snippets.

@zestime
Created March 13, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zestime/8cf8b4d7d5d176e5fa16 to your computer and use it in GitHub Desktop.
Save zestime/8cf8b4d7d5d176e5fa16 to your computer and use it in GitHub Desktop.
> /bbb(?=ccc)/.exec("aaabbbccc") // lookahead
["bbb"]
> /bbb(?=ccc)/.exec("dddbbbeee")
null
> /bbb(?!ccc)/.exec("aaabbbccc") // negative lookahead
null
> /bbb(?!ccc)/.exec("dddbbbeee")
["bbb"]
> /(?<=aaa)bbb/.exec("aaabbbccc") // lookbehind?
Uncaught SyntaxError: Invalid regular expression: /(?<=aaa)bbb/: Invalid group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment