Regular expression testing tools provide you with js regular expression verification, regular expression verification, regular expression verification, regular expression testing tools, online custom regular expressions to extract text content, for any regular expression Perform verification, regular expression extraction of URLs, regular expression online formatting, etc., I hope it will be helpful to everyone.
The role of regular expressions
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"). Regular expressions use a single string to describe and match a series of strings that match a certain syntax rule. Regular expressions are cumbersome, but they are powerful. The application after learning will not only improve your efficiency, but also bring you an absolute sense of accomplishment. Many programming languages support the use of regular expressions for string operations.
Common metacharacters
Code | Description |
---|---|
. | Match any character except newline |
\w | Match letters or numbers or underscore |
\s | Match any whitespace |
\d | Match numbers |
\b | Matches the beginning or end of a word |
^ | Matches the beginning of the string |
$ | Match end of string |
Common qualifiers
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 antonyms
code/syntax | Description |
---|---|
\W | Match any characters that are not letters, numbers, underscores, Chinese characters |
\S | Match any character that is not whitespace |
\D | Match any character that is not a number |
\B | Matches a position that is not the beginning or end of a word |
[^x] | Match any character except x |
[^aeiou] | Match any character except the letters aeiou |
Character | Description |
---|---|
^\d+$ | //Match non-negative integer (positive integer + 0) |
//Match integer ^\d+(\.\d+)?$ | //Match non-negative floating-point numbers (positive floating-point numbers + 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 floating-point numbers (negative floating-point numbers + 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]+$????????? | //Match a string consisting of 26 English letters |
^[A-Z]+$ ??? | //Match a string consisting of 26 uppercase English letters |
^[a-z]+$ | //Match a string consisting of 26 lowercase English letters |
^[A-Za-z0-9]+$ | //Match a string consisting of numbers and 26 English letters |
^\w+$ | //Match a string consisting of numbers, 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 for matching Chinese characters |
[^\x00-\xff] | Match double-byte characters (including Chinese characters) |
\n[\s| ]*\r | Regular expression to match empty lines |
/<(.*)>.*<\/>|<(.*)\/>/ | Regular expression to match HTML tags |
(^\s*)|(\s*$) | A regular expression that matches 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 URL |
^[a-zA-Z][a-zA-Z0-9_]{4,15}$ | Whether the matching account is legal (starting with a letter, allowing 5-16 bytes, allowing alphanumeric underscores) |
(\d{3}-|\d{4}-)?(\d{8}|\d{7})? | Match domestic phone numbers |
^[1-9]*[1-9][0-9]*$ | Match Tencent QQ number |
Popular tools: