Test JavaScript-compatible regular expressions against sample text, inspect matches, and try replacements in one place. It is useful for validation rules, search patterns, parsing, and debugging.
About regular expressions
Regular expressions describe text patterns using ordinary characters and metacharacters. They are supported by most programming languages and are especially useful for matching, extracting, validating, and replacing text.
| Character | Description |
|---|---|
| ^\d+$ | // Matching non-negative integers (positive integer + 0) |
| ^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 points |
| ^((-\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 points |
| ^(-?\d+)(\.\d+)?$ | // Matching Floats |
| ^[A-Za-z]+$????????? | // Match a string of 26 letters |
| ^[A-Z]+$ ??? | // Match a string of 26 letters in uppercase |
| ^[a-z]+$ | // Match a string of 26 letters of lowercase |
| ^[A-Za-z0-9]+$ | // Match a string of numbers and 26 letters |
| ^\w+$ | // Match strings consisting of numbers, 26 letters or underlineds |
| ^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$ | // Match email address |
| ^[a-zA-z] + \ \w+(-\w+*) (\w+(-\w+*)* (\?S*)?$? | // Matchurl |
| [\u4e00-\u9fa5] | Regular expression matching Chinese characters |
| [^\x00-\xff] | Match two bytes (including Han) |
| \n[\s| ]*\r | Regular expression matching empty lines |
| /<(.*)>.*<\/>|<(.*)\/>/ | Regular expression matching HTML tags |
| (^\s*)|(\s*$) | Regular expression matching the first-end spaces |
| \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* | Regular expression matching Email address |
| ^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$ | Regular expression matching URL URL |
| ^[a-zA-Z][a-zA-Z0-9_]{4,15}$ | Match the validity of account numbers (letter beginning, 5-16 bytes allowed, alphanumeric underlined) |
| (\d{3}-|\d{4}-)?(\d{8}|\d{7})? | Match domestic phone numbers |
| ^[1-9]*[1-9][0-9]*$ | Match to QQQ. |