Skip to content

Instantly share code, notes, and snippets.

@phamducminh
Created May 14, 2025 20:06
Show Gist options
  • Select an option

  • Save phamducminh/9a276f3e2ccdd652ed780db3fefc83cb to your computer and use it in GitHub Desktop.

Select an option

Save phamducminh/9a276f3e2ccdd652ed780db3fefc83cb to your computer and use it in GitHub Desktop.
Regular Exression

Meta Character

  • ? : Zero or One
  • + : One or More
  • * : Zero or More
  • \w : alpha numeric values
  • \d : digits or numbers
  • \s : space
  • [A-Z] : all capital letters
  • [a-z] : all lowercase letters
  • [0-9] : digit from 0 to 9
  • ^ : start with
  • $ : end with

Example:

  • (?=.*[A-Z]) : means at least one occurrence of a capita letter
  • (?=.*[!@&^%$]) : at least one special character

Quantifiers

  • {n} : Exactly n number of chars
  • {m,n} : A minimum of m chars and maximum of n chars
  • {m,} : Min m chars and max any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment