AppDevTools
AppDevTools
/
Validators
Regular Expression Tester

Regular Expression Tester

client
slash/gmflag
swap-vertical

Documentation

What is a regular expression?

A regular expression (also known as regex or regexp) is a search pattern consisting of a set of characters and optional flags. You can use a regular expression to define a search pattern to find data in a text.


Flags

Flags or modifiers in regular expressions are used to customize searching.

FlagDescription
gGlobal match - finds all matches instead of stopping at the first one
iIgnore case - performs a case insensitive search
mMultiline - allows ^ and $ to match start and end of line
uUnicode - enables full Unicode support
ySticky - starts searching at the lastIndex position
sSingleline - also known as "dotall", allows . to match newlines \n

Brackets

Brackets are used to search for characters in a given range in regular expressions.

ExpressionDescription
[...]One of the characters in the brackets
[^...]One of the characters NOT in the brackets
[a-z]One of the characters from a to z
[^a-z]One of the characters NOT from a to z
[A-Z]One of the characters from A to Z
[^A-Z]One of the characters NOT from A to Z
[0-9]One of the characters from 0 to 9 (a digit character)
[^0-9]One of the characters NOT from 0 to 9 (a non-digit character)

Groups

Groups in regular expressions are part of a search pattern enclosed in parentheses (...).

ExpressionDescription
(...)A capturing group
(?:...)A non-capturing group
(a|b)Either a or b

Character Classes

Character classes are characters with a special meaning to define search patterns in regular expressions.

CharacterDescription
.A single character except newline \n
\dA digit character. Equivalent to [0-9].
\DA non-digit character. Equivalent to [^0-9].
\wA word character. An alphanumeric character including underscore. Equivalent to [a-zA-Z0-9_].
\WA non-word character. NOT an alphanumeric character including underscore. Equivalent to [^a-zA-Z0-9_].
\sA whitespace character
\SA non-whitespace character
[\b]A literal backspace character

Special Characters

CharacterDescription
\An escape character
\0A null character
\nA newline character
\tA tab character
\vA vertical tab character
\rA carriage return character
\fA form feed character
\cXA control character where X is a character from A-Z
\oooThe character specified by three octal digits
\xhhThe character specified by two hexadecimal digits
\uhhhhThe Unicode character specified by four hexadecimal digits

Quantifiers

Quantifiers in regular expressions specify the number of occurrences a character, character class, or group must be present.

CharacterDescription
*Zero or more times
?Zero or one time
+One or more times
{n}Exactly n times
{n,m}n to m times
{n,}n times or more

Assertions

Assertions are regular expressions consisting of anchors and lookaheads that cause a match to succeed if found or fail otherwise.

CharacterDescription
^Start of string or line
$End of string or line
\bA word boundary
\BA non-word boundary
(?=...)Positive lookahead
(?!...)Negative lookahead

Related Tools

HTML Validator

Validates HTML code against the W3C standards instantly as known as HTML linter. Supports partial HTML code validation. Errors and warnings including line numbers and excerpt code will be printed if any.

JSON Validator

Validates JSON data against the JSON specification instantly as known as JSON linter. Errors including line numbers and excerpt code will be printed if any.

YAML Validator

Validates YAML data against the YAML specification instantly as known as YAML linter. Errors including line numbers and excerpt code will be printed if any.

Credit Card Validator

Safely validates a credit card number instantly to check if it's a valid card and find the card type. Completely works on your browser for your safety and privacy.

Share