Created
March 27, 2015 17:37
-
-
Save jdaily/d45a40022687ae94ffb6 to your computer and use it in GitHub Desktop.
Regular Expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
US Domestic Phone Numbers | |
\(\d{1,3}\)([\s\.\-])\d{3,4}(?:\1|\-)?\d{4,6}\b | |
International Phone Numbers | |
\+\d{1,3}([\s\.\-])(?:\(\d{1,3}\)|\d{1,3})\1\d{3,4}(?:\1|\-)?\d{4,6}\b | |
Street Address | |
\b\d{1,7}(?:\-?[A-Z]?|st|nd|rd|th)(?:\s[\w']+){1,4}\s(?:W|E|N|S|NE|NW|SE|SW|ave|ct|street|st|dr|ln|rd|blvd)\b | |
US City and State | |
\b[A-Z][a-z]{2,}\,\s(?:(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]))\b | |
SSN | |
\b(?<!\-)\d{3}\-\d\d\-\d{4}\b(?!\-) | |
\b[A-Za-z\d\-_][A-Za-z\d\-_\.\+]*@(?:[A-Za-z\d][A-Za-z\d\-]*[A-Za-z\d]\.)+[A-Za-z]{2,7}\b(?!\.) | |
Credit Cards | |
Amex | |
\b3[47]\d\d([\-\ ]?)\d{6}\1\d{5}\b | |
MC | |
\b5[1-5]\d\d([\-\ ]?)(?:\d{4}\1){2}\d{4}\b | |
VI | |
\b4\d{3}([\-\ ]?)(?:\d{4}\1){2}\d(?:\d{3})?\b | |
DISC | |
\b6(?:01|22|4[4-9]|5\d)\d([\-\ ]?)(?:\d{4}\1){2}\d{4}\b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment