Skip to content

Instantly share code, notes, and snippets.

@ColtHands
Last active September 9, 2022 13:26
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 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 hello+world@mail.com

  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