Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Regular Expressions List
//Regular Expressions List
//Short Tutorial
\ // the escape character - used to find an instance of a metacharacter like a period, brackets, etc.
. // match any character except newline
x // match any instance of x
^x // match any character except x
[x] // match any instance of x in the bracketed range - [abxyz] will match any instance of a, b, x, y, or z
| // an OR operator - [x|y] will match an instance of x or y
() // used to group sequences of characters or matches
{} // used to define numeric quantifiers
{x} // match must occur exactly x times
{x,} // match must occur at least x times
{x,y} // match must occur at least x times, but no more than y times
? // preceding match is optional or one only, same as {0,1}
* // find 0 or more of preceding match, same as {0,}
+ // find 1 or more of preceding match, same as {1,}
^ // match the beginning of the line
$ // match the end of a line
[:alpha:] // Represents an alphabetic character. Use [:alpha:]+ to find one of them.
[:digit:] // Represents a decimal digit. Use [:digit:]+ to find one of them.
[:alnum:] // Represents an alphanumeric character ([:alpha:] and [:digit:]).
[:space:] // Represents a space character (but not other whitespace characters).
[:print:] // Represents a printable character.
[:cntrl:] // Represents a nonprinting character.
[:lower:] // Represents a lowercase character if Match case is selected in Options.
[:upper:] // Represents an uppercase character if Match case is selected in Options.
\d // matches a digit, same as [0-9]
\D // matches a non-digit, same as [^0-9]
\s // matches a whitespace character (space, tab, newline, etc.)
\S // matches a non-whitespace character
\w // matches a word character
\W // matches a non-word character
\b // matches a word-boundary (NOTE: within a class, matches a backspace)
\B // matches a non-wordboundary
// Email address
^([\w\.*\-*]+@([\w]\.*\-*)+[a-zA-Z]{2,9}(\s*;\s*[\w\.*\-*]+@([\w]\.*\-*)+[a-zA-Z]{2,9})*)$ //List of semi-colon seperated email addresses
// IP Address
// Credit Cards
// Username of type test@test
// Multiple spaces replacement
// Non-alphanumeric replacement
// Blank line
// Positive integers
// Positive decimal values
// Percentage (2 decimal places)
// State abbreviation
[A-Z][A-Z] //you may choose to put spaces either before or after the regex.
// Phone Numbers
// City, State abbreviation
.*, [A-Z][A-Z]
// Zip Code
[0-9]\{5\}(-[0-9]\{4\})? //84094 or 84094-1234
// Social security number, such as: ###-##-####
// Dollar amounts, specified with a leading $ symbol
[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} //2003-08-06
[A-Z][a-z][a-z] [0-9][0-9]*, [0-9]\{4\} //Jan 3, 2003
^(\d{1,2})\/(\d{1,2})\/(\d{2}|(19|20)\d{2})$ //DD/MM/YY or DD/MM/YYYY or MM/DD/YY or MM/DD/YYYY
// HTML Tags except <p> </p>
// Font Tags Replacement
<(FONT|font)([ ]([a-zA-Z]+)=("|')[^"\']+("|'))*[^>]+>([^<]+)(</FONT>|</font>
// URL
^http(s)?:\/\/((\d+\.\d+\.\d+\.\d+)|(([\w-]+\.)+([a-z,A-Z][\w-]*)))(:[1-9][0-9]*)?(\/([\w-.\/:%+@&=]+[\w- .\/?:%+@&=]*)?)?(#(.*))?$/i
// NOTEPAD ++ Replace
// Insert a span in anchor
Find : (<a.*>)(.*)</a>
Replace : \1<span class="icon3 pdf">\2</span></a>
Copy link

kayode-adechinan commented May 8, 2018

Waoh fantastic! God bless you

Copy link

erikfenriz commented May 19, 2018

Nicely done. Ty

Copy link

rodrigoramirez93 commented May 23, 2018

Great! Thank you!

Copy link

juanpablocs commented Jan 6, 2020

these are missing:


Copy link

muzammilsiddiq commented Jun 29, 2021

Kindly add a regular expression for strong, medium, and weak passwords.

Copy link

TranQuocToan1996 commented Aug 2, 2021

wow thank you so much.

Copy link

ghost commented Sep 24, 2021

It is very useful for me. Thanks

Copy link

Afonso-S-Araujo commented Feb 24, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment