About the Regex Tester
What is Regular Expression?
Regular expressions (regex) are powerful tools for pattern matching and string manipulation. They use a specific syntax to define search patterns for input validation, content extraction, text replacement and more. Almost all major programming languages support regex.
Syntax Reference
| Syntax | Description | Example |
|---|---|---|
| \d | Digit | \d+ → "123" |
| \w | Word char | \w+ → "hello" |
| \s | Whitespace | \s → " " |
| . | Any char | a.b → "aab" |
| * | Zero or more | a* → "" / "aaa" |
| + | One or more | a+ → "a" / "aaa" |
| ? | Zero or one | a? → "" / "a" |
| {n,m} | n to m times | a{2,4} → "aa"~"aaaa" |
| [abc] | Char class | [aeiou] → vowel |
| [^abc] | Negated class | [^0-9] → non-digit |
| ^ | Start of line | ^Hello |
| $ | End of line | end$ |
| ( ) | Capture group | (\d+)-(\d+) |
| (?: ) | Non-capturing | (?:ab)+ |
| | | Alternation | cat|dog |