Skip to content

Instantly share code, notes, and snippets.

@mwj8410
Last active July 27, 2018 14:59
Show Gist options
  • Save mwj8410/850a650c800882b09bf011044698bee0 to your computer and use it in GitHub Desktop.
Save mwj8410/850a650c800882b09bf011044698bee0 to your computer and use it in GitHub Desktop.
Common Regular Expressions

Common Regular Expression

Password Validation

/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])^\S{6,20}$/

  • Contians a digit
  • Contains a lowercase letter
  • Contains an upper case letter
  • is between 6 and 20 non-whitespace characters in length

Semantic Version

/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b/

  • May or may not start with a 'v'
  • 3 sets of digits seperated by '.'

UUIDv4

^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-(a|b|9|8)[0-9a-f]{3}-[0-9a-f]{12}$

00000000-0000-4000-a000-000000000000

Editing

Missing Oxford Comma

([a-z]+ +){2,}(and|or) +[a-z]+

Oxford comma

([a-z]+, +){2,}(and|or) +[a-z]+

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