The regular expression test tool provides js regular expression validation, regex verification and regex testing. You can use a custom regular expression online to extract text, validate any regular expression, extract URLs with a regex and format regex online. We hope it is helpful to everyone.
What regular expressions do
A regular expression (Regular Expression) is a text pattern that includes ordinary characters (for example the letters between a and z) and special characters (called "metacharacters"). A regular expression uses a single string to describe and match a series of strings that follow a syntactic rule. Regular expressions are tedious but powerful; mastering them not only improves efficiency but gives you an absolute sense of achievement. Many programming languages support string operations with regular expressions.
Common metacharacters| Code | Description |
|---|---|
| . | Matches any character except a newline |
| \w | Matches letters, digits or underscores |
| \s | Match any whitespace |
| \d | Match digits |
| \b | Match the start or end of a word |
| ^ | Match start of string |
| $ | Match end of string |
Common quantifiers| Code/Syntax | Description |
|---|---|
| * | Repeat zero or more |
| + | Repeat once or more |
| ? | Repeat zero or one time |
| {n} | Repeat n times |
| {n,} | Repeat n or more |
| {n,m} | Repeat n to m times |
Common antonyms| Code/Syntax | Description |
|---|---|
| \W | Match any character that is not a letter, digit, underscore or Chinese character |
| \S | Matches any non-whitespace character |
| \D | Matches any non-digit character |
| \B | Match a position that is not a word start or end |
| [^x] | Matches any character except x |
| [^aeiou] | Match any character except the letters aeiou |
| Character | Description |
|---|---|
| ^\d+$ | //Matches a non-negative integer (positive integer + 0) |
| // Match an integer ^\d+(\.\d+)?$ | //Match non-negative floats (positive floats + 0) |
| ^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$ | // Match positive floating-point numbers |
| ^((-\d+(\.\d+)?)|(0+(\.0+)?))$ | //Match non-positive floats (negative floats + 0) |
| ^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$ | // Match negative floating-point numbers |
| ^(-?\d+)(\.\d+)?$ | // match floating-point numbers |
| ^[A-Za-z]+$????????? | //Matches a string made up of the 26 English letters |
| ^[A-Z]+$ ??? | //Match a string composed of the 26 uppercase English letters |
| ^[a-z]+$ | //Match a string composed of the 26 lowercase English letters |
| ^[A-Za-z0-9]+$ | //Match a string composed of digits and the 26 English letters |
| ^\w+$ | //Match a string composed of digits, the 26 English letters or underscores |
| ^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$ | // Match email address |
| ^[a-zA-z]+://match (\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$ | // match url |
| [\u4e00-\u9fa5] | Regex for matching Chinese characters |
| [^\x00-\xff] | Matches double-byte characters (including Han characters) |
| \n[\s| ]*\r | Regex matching empty lines |
| /<(.*)>.*<\/>|<(.*)\/>/ | Regex for matching HTML tags |
| (^\s*)|(\s*$) | Regex matching leading and trailing whitespace |
| \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* | Regular expression that matches Email addresses |
| ^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$ | Regex for matching URLs |
| ^[a-zA-Z][a-zA-Z0-9_]{4,15}$ | Check whether an account name is valid (starts with a letter, 5-16 bytes, letters, digits and underscores allowed) |
| (\d{3}-|\d{4}-)?(\d{8}|\d{7})? | Match domestic phone numbers |
| ^[1-9]*[1-9][0-9]*$ | Match Tencent QQ numbers |
This tool belongs to the “Code & markup formatting” category.
Your input is processed locally in the browser whenever possible. We do not store it.
Formatting expands code into indented lines for readability; minifying strips whitespace and comments to reduce size.
Only whitespace, line breaks and comments are touched. With JavaScript that relies on automatic semicolon insertion, test the minified output before shipping.
Formatting and minifying run client-side. Nothing is written to server logs.