Regex Tester
Test your regular expressions in real-time. Supports JavaScript regex flavor syntax and flags.
/
/
4 matches
What is a Regular Expression (Regex)?
A Regular Expression (often abbreviated as regex or regexp) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation.
Regex is supported in nearly all modern programming languages (JavaScript, Python, Java, C#, etc.), though the exact syntax (the "flavor") can vary slightly. This tool uses the JavaScript (ECMAScript) regex flavor.
Common Regex Patterns
| Pattern | Description | Example Match |
|---|---|---|
| \d | Any digit (0-9) | 1, 5 |
| \w | Any word character (alphanumeric + underscore) | A, b, 3, _ |
| \s | Any whitespace character (space, tab, newline) | |
| . | Any character except newline | x, &, @ |
| ^ / $ | Start of string / End of string | - |
| * / + / ? | 0 or more / 1 or more / 0 or 1 of the previous token | - |
| [a-z] | Any character in the specified range | m, q |
Regex Flags Explained
Flags (or modifiers) change how the expression searches the string. In JavaScript, they are appended after the closing slash of the regular expression (e.g., /pattern/g).
- g (Global): Don't return after the first match. Find all matches in the test string.
- i (Case Insensitive): Match both uppercase and lowercase letters.
/a/imatches both "a" and "A". - m (Multiline): Changes the behavior of
^and$to match the start and end of individual lines, rather than the whole string. - s (DotAll): Allows the dot (
.) to match newline characters.