Skip to content

Instantly share code, notes, and snippets.

@ColtHands
Last active September 9, 2022 13:26
Show Gist options
  • Save ColtHands/b2314acb1d15053f46fd99cf963be035 to your computer and use it in GitHub Desktop.
Save ColtHands/b2314acb1d15053f46fd99cf963be035 to your computer and use it in GitHub Desktop.
JS RegExp Snippets

JS RegExp Snippets

Match a string between two characters

(?<=\+)(.*)(?=\@) will match world in [email protected]

  1. start at + with (?<=\+)
  2. select all characters with (.*)
  3. end at @ with (?-\@)

Match the string exactly

^MATCHER$ $[5-6]^ will match "5" $[5-6]^ will not match "7" $[5-6]^ will not match "55"

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