Regular expression tester introduction

The regular expression tester provides JS regular expression validation, regular expression verification, regular expression testing tool, online custom regular expression to extract text content, verification of any regular expression, regular expression to extract URLs, online formatting of regular expressions, etc. Hope it helps.


The role of regular expressions

Regular Expression is a text pattern consisting of ordinary characters (e.g., letters a to z) and special characters (called \"metacharacters\"). Regular expressions use a single string to describe and match a series of strings that conform to a certain syntactic rule. Regular expressions can be tedious, but they are powerful. After learning them, besides improving efficiency, they will give you a sense of accomplishment. Many programming languages support using regular expressions for string operations.

Common metacharacters
Code Description
. Matches any character except newline
\w Matches letters, numbers, or underscores
\s Matches any whitespace character
\d Matches a digit
\b Matches the beginning or end of a word
^ Matches the beginning of a string
$ Matches the end of a string
Common quantifiers
Code/Syntax Description
* Repeat zero or more times
+ Repeat one or more times
? Repeat zero or one time
{n} Repeat n times
{n,} Repeat n or more times
{n,m} Repeat n to m times
Common negations
Code/Syntax Description
\W Matches any character that is not a letter, digit, underscore, or Chinese character
\S Matches any character that is not whitespace
\D Matches any non-digit character
\B Matches a position that is not the beginning or end of a word
[^x] Matches any character except x
[^aeiou] Matches any character except the letters aeiou

Regular expression reference

Character Description
^\d+$ // Match non-negative integer (positive integer + 0)
// Match integer ^\d+(\.\d+)?$ // Match non-negative floating point number (positive floating point number + 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 number
^((-\d+(\.\d+)?)|(0+(\.0+)?))$ // Match non-positive floating point number (negative floating point number + 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 number
^(-?\d+)(\.\d+)?$ // Match floating point number
^[A-Za-z]+$????????? // Match a string consisting of 26 English letters
^[A-Z]+$ ??? // Match a string consisting of uppercase 26 English letters
^[a-z]+$ // Match a string consisting of lowercase 26 English letters
^[A-Za-z0-9]+$ // Match a string consisting of digits and 26 English letters
^\w+$ // Match a string consisting of digits, 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] Regular expression to match Chinese characters
[^\x00-\xff] Match double-byte characters (including Chinese characters)
\n[\s| ]*\r Regular expression to match blank lines
/<(.*)>.*<\/>|<(.*)\/>/ Regular expression to match HTML tags
(^\s*)|(\s*$) Regular expression to match leading and trailing spaces
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* Regular expression to match email addresses
^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$ Regular expression to match URLs
^[a-zA-Z][a-zA-Z0-9_]{4,15}$ Match whether the account is valid (starting with a letter, allowing 5-16 bytes, allowing letters, numbers, underscores)
(\d{3}-|\d{4}-)?(\d{8}|\d{7})? Match domestic telephone numbers
^[1-9]*[1-9][0-9]*$ Match Tencent QQ number
Your Footprints: