Extract Regex Matches
Extract regular expression matches from text.
Give Rating
Online Regex Extractor
How to extract text matches using regular expression?
- Enter text in Input text area.
- Enter the regular expression in
Regular Expressioninput. - Choose a separator. (Default is space)
- Click on
Show Outputto get the exctracted matches.
Uses
- re extract
- regex find/match
Common Regular Expression/Regex Patterns
- Whole Numbers –
/^\d+$/ - Decimal Numbers –
/^\d*\.\d+$/ - Whole + Decimal Numbers –
/^\d*(\.\d+)?$/ - Negative, Positive Whole + Decimal Numbers –
/^-?\d*(\.\d+)?$/ - Whole + Decimal + Fractions –
/[-]?[0-9]+[,.]?[0-9]*([\/][0-9]+[,.]?[0-9]*)*/ - Alphanumeric without space –
/^[a-zA-Z0-9]*$/ - Alphanumeric with space –
/^[a-zA-Z0-9 ]*$/ - Common email Ids –
/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/ - Alphanumeric string that may include _ and – having a length of 3 to 16 characters –
/^[a-z0-9_-]{3,16}$/ - Include http(s) Protocol
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&//=]*)/ - Protocol Optional
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/ - Match IPv4 address
/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/ - Match IPv6 address
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-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f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/ - Date Format YYYY-MM-dd
/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/ - Date Format dd-mmm-YYYY or dd/mmm/YYYY or dd.mmm.YYYY
/^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/ - Time Format HH:MM 12-hour, optional leading 0, Meridiems (AM/PM)
/((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))/ - Time Format HH:MM 24-hour, optional leading 0
/^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/ - Time Format HH:MM:SS 24-hour
/(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)/ - HTML Elements with Attributes
/<\/?[\w\s]*>|<.+[\W]>/ - Search Duplicates
/(\b\w+\b)(?=.*\b\1\b)/ - International Phone Numbers
/^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/ - File Path with Filename and extension
/((\/|\\|\/\/|https?:\\\\|https?:\/\/)[a-z0-9 _@\-^!#$%&+={}.\/\\\[\]]+)+\.[a-z]+$/ - Social Security Number
/^((?!219-09-9999|078-05-1120)(?!666|000|9\d{2})\d{3}-(?!00)\d{2}-(?!0{4})\d{4})|((?!219 09 9999|078 05 1120)(?!666|000|9\d{2})\d{3} (?!00)\d{2} (?!0{4})\d{4})|((?!219099999|078051120)(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4})$/ - Passport –
/^[A-PR-WY][1-9]\d\s?\d{4}[1-9]$/ - City, State abbreviation -
/.*, [A-Z][A-Z]/ - Credit Card -
/(^4[0-9]{12}(?:[0-9]{3})?$)|(^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$)|(3[47][0-9]{13})|(^3(?:0[0-5]|[68][0-9])[0-9]{11}$)|(^6(?:011|5[0-9]{2})[0-9]{12}$)|(^(?:2131|1800|35\d{3})\d{11}$)/ - Emoji -
/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/ - Latitude & Longitude -
/^((\-?|\+?)?\d+(\.\d+)?),\s*((\-?|\+?)?\d+(\.\d+)?)$/ - MAC Address -
/^[a-fA-F0-9]{2}(:[a-fA-F0-9]{2}){5}$/ - Bitcoin Address -
/^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/ - Indian PAN from GSTIN -
/^([0][1-9]|[1-2][0-9]|[3][0-5])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1})([1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$/ - Digital Object identifier -
/^(10\.\d{4,5}\/[\S]+[^;,.\s])$/ - Hashtags -
/^#[^ !@#$%^&*(),.?":{}|<>]*$ - Telehphone Numbers -
/+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9} - e.164 phone number -
/^\+[1-9]\d{1,14}$/ - Arabic characters -
/[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufbc1]|[\ufbd3-\ufd3f]|[\ufd50-\ufd8f]|[\ufd92-\ufdc7]|[\ufe70-\ufefc]|[\uFDF0-\uFDFD]/
For Pin/Zip codes
- US -
^\d{5}([\-]?\d{4})?$ - UK -
^(GIR|[A-Z]\d[A-Z\d]??|[A-Z]{2}\d[A-Z\d]??)[ ]??(\d[A-Z]{2})$ - DE -
\b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b - CA -
^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$ - FR -
^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$ - IT -
^(V-|I-)?[0-9]{5}$ - AU -
^(0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2})$ - NL -
^[1-9][0-9]{3}\s?([a-zA-Z]{2})?$ - ES -
^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$ - DK -
^([D|d][K|k]( |-))?[1-9]{1}[0-9]{3}$ - SE -
^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$ - BE -
^[1-9]{1}[0-9]{3}$ - IN -
^\d{6}$
Regular Expression Cheatsheet
| Expression | Usage |
|---|---|
\n |
Newline |
\r |
Carriage Return |
\t |
Tab |
\0 |
Null Character |
[abc] |
a single character in brackets |
[^abc] |
a single character not in brackets |
[a-zA-Z] |
any characters between a-z or A-Z |
. |
any single character |
a|b |
either character |
\s |
any whitespace character |
\S |
any non-whitespace character |
\d |
any digit |
\D |
any non-digit |
\w |
any word character |
\W |
any non-word character |
\X |
any unicode sequence |
\C |
one data unit |
\R |
unicode newlines |
a{3,} |
3 or more of a |
^ |
Start of string |
$ |
end of string |
\b |
word boundary |
\B |
non-word boundary |