Skip to content

Instantly share code, notes, and snippets.

@pierr
Last active August 29, 2015 14:26
Show Gist options
  • Save pierr/4e82ed29014bb87c91cc to your computer and use it in GitHub Desktop.
Save pierr/4e82ed29014bb87c91cc to your computer and use it in GitHub Desktop.

Regular expression are used for many things. It whould be complex to write code to check validation.

There is two part:

  • The string to search in
  • The regular expression
  • Regular erxpression starts and end with a //
  • The operator OR is |
  • It can matches letter or number or special character
  • There are used mainly for validation, searching, formatting
  • Repeat a pattern /ar+ , the plus operator repeat the letter until there is no more of it.
  • james and jameasson
  • A chartacter set is [a-z], match one character from a to z
  • /[a-z]+/i i operator is a modifier saying don't care about the case
  • How to deal with white space \s it stands for tabs, space and almost everything.
  • /[a-z0-9\s]+/i
  • \w is the same as [a-zA-Z0-9] ``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment