Introduction to Regular Expression Testing Tools

Regular Expression Testing Tools provide you with JavaScript regular expression validation, regular expression verification, regular expression checking, and online custom regular expressions to extract text content. It allows for the validation of any regular expression, extraction of URLs using regular expressions, online formatting of regular expressions, etc. We hope this will be helpful to you.


The Role of Regular Expressions

A Regular Expression (Regex) is a text pattern that includes both ordinary characters (e.g., letters from a to z) and special characters known as "metacharacters." Regular expressions use a single string to describe and match a series of strings that adhere to a certain syntactic rule. Regular expressions can be cumbersome, but they are powerful. Once mastered, their application will not only increase your efficiency but also bring you a sense of accomplishment. Many programming languages support string operations using regular expressions.

Common Metacharacters
Code Description
. Matches any single character except for a newline
\w Matches any alphanumeric character including the underscore
\s Matches any whitespace character
\d Matches any digit
\b Matches a word boundary
^ Matches the start of a string
$ Matches the end of a string
Common Quantifiers
Code/Syntax Description
* Repeats zero or more times
+ Repeats one or more times
? Repeats zero or one time
{n} Repeats exactly n times
{n,} Repeats at least n times
{n,m} Repeats between n and m times, inclusive
Common Negations
Code/Syntax Description
\W Matches any character that is not a word character (alphanumeric plus underscore, and Chinese characters are considered word characters in some regex flavors but not universally)
\S Matches any character that is not a whitespace character
\D Matches any character that is not a digit
\B Matches a position that is not a word boundary
[^x] Matches any character except 'x'
[^aeiou] Matches any character except the letters 'a', 'e', 'i', 'o', and 'u'

Comprehensive Regular Expression Reference

Character/Pattern Description
^\d+$ Matches a non-negative integer (positive integer + 0)
^\d+(\.\d+)?$ Matches a 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]*))$ Matches a positive floating-point number
^((-\d+(\.\d+)?)|(0+(\.0+)?))$ Matches a 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]*)))$ Matches a negative floating-point number
^(-?\d+)(\.\d+)?$ Matches a floating-point number
^[A-Za-z]+$ Matches a string composed of 26 English letters (both uppercase and lowercase)
^[A-Z]+$ Matches a string composed of 26 uppercase English letters
^[a-z]+$ Matches a string composed of 26 lowercase English letters
^[A-Za-z0-9]+$ Matches a string composed of digits and 26 English letters (both uppercase and lowercase)
^\w+$ Matches a string composed of digits, 26 English letters, or underscores
^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$ Matches an email address
^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$ Matches a URL
[\u4e00-\u9fa5] Regular expression to match Chinese characters
[^\x00-\xff] Matches 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 or trailing whitespace
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* Regular expression to match email addresses (alternate pattern)
^[a-zA-Z][a-zA-Z0-9_]{4,15}$ Matches a valid account (starts with a letter, allows 5-16 characters, including letters, digits, and underscores)
(\d{3}-|\d{4}-)?(\d{8}|\d{7})? Matches domestic telephone numbers
^[1-9]*[1-9][0-9]*$ Matches Tencent QQ numbers