Regex tester online free — test regular expressions instantly

Test JavaScript regular expressions with live matches and captured groups in your browser.

Matches found: 7
«Paste» «text» «here» to «test» «regular» «expressions» «quickly».
Match list
1. "Paste" at index 0
2. "text" at index 6
3. "here" at index 11
4. "test" at index 19
5. "regular" at index 24
6. "expressions" at index 32
7. "quickly" at index 44

How this tool fits your workflow

More in this category →

Regular expression syntax quick reference

A regular expression is a pattern that describes a set of strings. The most common elements: . matches any character except newline; * means zero or more; + means one or more; ? means zero or one. Character classes like [a-z] match any lowercase letter; [^0-9] matches anything that is not a digit. ^ anchors to the start of a line; $ anchors to the end.

Groups and alternation: parentheses () create capture groups — matched text can be referenced with $1, $2, etc. in replacements. (?:...) is a non-capturing group. The | operator means OR: cat|dog matches either "cat" or "dog". Quantifiers can be made lazy (match as few characters as possible) by appending ?: .*? matches the shortest possible sequence.

Common regex flags

Flags modify how a pattern matches. The g (global) flag finds all matches instead of stopping at the first. The i (case-insensitive) flag makes uppercase and lowercase letters interchangeable. The m (multiline) flag changes ^ and $ to match the start and end of each line rather than the whole string. The s (dotAll) flag makes . match newline characters too.

In JavaScript, flags are appended after the closing slash: /pattern/gi. The u flag enables full Unicode mode, treating the string as a sequence of Unicode code points rather than UTF-16 code units — important for matching emoji and non-BMP characters correctly.

Patterns for common validation tasks

Email (simplified): /^[^\s@]+@[^\s@]+\.[^\s@]+$/. This is not RFC 5322 compliant but catches most real-world valid emails. Full RFC compliance requires a large regex — use a library for production validation.

URL: /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/. Phone (US): /^\+?1?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/. ISO date: /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/.

Lookaheads and lookbehinds let you match text only when followed or preceded by a pattern, without including that context in the match. Positive lookahead: \d+(?= dollars) matches digits followed by " dollars". Negative lookbehind: (?<!un)happy matches "happy" not preceded by "un".

Performance pitfalls: catastrophic backtracking

Some regex patterns cause exponential backtracking on certain inputs, making the engine appear to hang. The classic example is (a+)+ applied to a long string of "a" characters followed by a character that does not match. The engine tries all possible groupings before failing — exponential work for a linear-length string.

To avoid this: prefer atomic groups or possessive quantifiers where your engine supports them. Avoid nested quantifiers ((a*)*). Use anchors (^ and $) to fail fast. When validating untrusted input with regex in a server context, set a timeout or use a linear-time regex engine. The browser context on this page is forgiving — a slow pattern will just freeze the page temporarily rather than causing a server outage.

Frequently asked questions

What regex flags are supported?
All JavaScript regex flags: g (global), i (case insensitive), m (multiline), s (dotAll), u (unicode), y (sticky). Toggle each flag independently to test different matching behaviors.
Can I test capture groups?
Yes. The match list shows all captured groups for each match. Use parentheses in your pattern to create capture groups, and the tool displays them alongside the full match.
Does this work for other programming languages?
This tool uses JavaScript regex engine. While most basic patterns work across languages, advanced features like lookbehinds, named groups, and flags may differ. Test in your target language for production code.
Is my test data sent to servers?
No. Pattern matching runs entirely in your browser with JavaScript RegExp. Your patterns and test strings never leave your device.