Skip to content

Instantly share code, notes, and snippets.

@bmcminn
Created March 4, 2016 22:55
Show Gist options
  • Select an option

  • Save bmcminn/fc5412bd19eccea97eaf to your computer and use it in GitHub Desktop.

Select an option

Save bmcminn/fc5412bd19eccea97eaf to your computer and use it in GitHub Desktop.
Some of my favorite/most useful regexes. NOTE: these are not meant for validating, mostly just capturing whole strings or partials.
{
cComments: /\/\*[\s\S]*?\*\/|\/\/[\s\S]*?(?=\n)/g
, emails: /[\S]+@[\S]+/gi
/* EMAIL TEST
testing@test.com
waffles+tasty@gmail.com
wafe.23@gdsjkl-23.org
falawefjsl_23423@wesjkle.co.uk
falawefjsl_23423@wesjkle.ru
*/
, phones: {
usPhones: /(^((\+1\s?))?[^\d\s]*\(?(\d{3})[^\d]*(\d{3})[^\d]*(\d{4}))/gi
/* US PHONE TEST
5125551234
512-555-1234
512.555.1234
+1 512-555-1234
+1.512.555.1234
+1(512)555-1234
+1(512)555.1234
(512)555-1234
(512)555.1234
(512) 555-1234
(512) 555.1234
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment