Introduction to Regular Expression Testing Tool

The Regular Expression Testing Tool provides you with JS regular expression validation, regular expression checking, and testing tools. You can customize regular expressions online to extract text content, validate any regular expression, extract URLs, and format regular expressions online. We hope it will be helpful to everyone.


Purpose of Regular Expressions

A regular expression (Regular Expression) is a text pattern that includes ordinary characters (like letters from a to z) and special characters (known as "metacharacters"). A regular expression uses a single string to describe and match a set of strings that conform to a certain syntax rule. Regular expressions are complex but powerful; once mastered, they can significantly enhance your efficiency and provide a great sense of accomplishment. Many programming languages support string operations using regular expressions.

Common Metacharacters
CodeDescription
.Matches any character except a newline
\wMatches a letter, digit, or underscore
\sMatches any whitespace character
\dMatches a digit
\bMatches the start or end of a word
^Matches the start of a string
$Matches the end of a string
Common Quantifiers
Code/SyntaxDescription
*Repeats zero or more times
+Repeats one or more times
?Repeats zero or one time
{n}Repeats n times
{n,}Repeats n times or more
{n,m}Repeats n to m times
Common Negations
Code/SyntaxDescription
\WMatches any character that is not a letter, digit, underscore, or Chinese character
\SMatches any character that is not a whitespace
\DMatches any non-digit character
\BMatches a position that is not at the start or end of a word
[^x]Matches any character except x
[^aeiou]Matches any character except for the letters a, e, i, o, u

Comprehensive Reference for Regular Expressions

CharacterDescription
^\d+$// Matches non-negative integers (positive integers + 0)
// Matches integers ^\d+(\.\d+)?$// Matches 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]*))$// Matches positive floating point numbers
^((-\d+(\.\d+)?)|(0+(\.0+)?))$// Matches 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]*)))$// Matches negative floating point numbers
^(-?\d+)(\.\d+)?$// Matches floating point numbers
^[A-Za-z]+$// Matches strings composed of 26 letters
^[A-Z]+$// Matches strings composed of 26 uppercase letters
^[a-z]+$// Matches strings composed of 26 lowercase letters
^[A-Za-z0-9]+$// Matches strings composed of digits and 26 letters
^\w+$// Matches strings composed of digits, 26 letters, or underscores
^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$// Matches email addresses
^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$// Matches URLs
[\u4e00-\u9fa5]// Matches Chinese characters
[^\x00-\xff]// Matches double-byte characters (including Chinese characters)
\n[\s| ]*\r// Matches empty lines
/<(.*)>.*<\/>|<(.*)\/>/// Matches HTML tags
(^\s*)|(\s*$)// Matches leading and trailing spaces
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*// Matches email addresses
^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$// Matches URLs
^[a-zA-Z][a-zA-Z0-9_]{4,15}$// Matches valid account names (starting with a letter, allowing 5-16 characters, letters, digits, and underscores)
(\d{3}-|\d{4}-)?(\d{8}|\d{7})?// Matches domestic phone numbers
^[1-9]*[1-9][0-9]*$// Matches Tencent QQ numbers
Your Footprints:

Friendly Links: PM EVE PM EVE