Skip to content

Instantly share code, notes, and snippets.

@roulette6
Last active March 23, 2017 12:12
Show Gist options
  • Save roulette6/cc475d19ad21c6c3c1ef4f3cfbdb16da to your computer and use it in GitHub Desktop.
Save roulette6/cc475d19ad21c6c3c1ef4f3cfbdb16da to your computer and use it in GitHub Desktop.

Practice sites

  • RegEx 101 - Handles PCRE (PHP), JavaScript, and Python
  • RegExr - Lets you test replacing using capture groups. Cannot handle lookbehinds b/c JavaScript only
  • regex one - Has lessons

RegEx metachars and symbols

Metachar Meaning
\n newline
\w word char [a-zA-Z0-9_]
\W not word char
\d digit
\s space
^ start of string
$ end of string
. any char except newline
* 0 or more of prev expression
+ 1 or more of prev expression
? make prev expression optional
` `
{...} explicit quantifier {2}, {2,5}
[...] explicit set of chars
[^...] exclude explicit set of chars
(...) capturing group
(?:...) don't create capturing group
(?=) positive lookahead
(?!) negative lookahead
(?<=) positive lookbehind
(?<!) negative lookbehind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment