Skip to content

Instantly share code, notes, and snippets.

@bmcminn
Created March 4, 2016 22:55
Show Gist options
  • Save bmcminn/fc5412bd19eccea97eaf to your computer and use it in GitHub Desktop.
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
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
*/
, 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