Regex Tester
Test a regex against your text with live highlighting, match list and flag toggles. Common-pattern dropdown.
Quick answer: Test a regex against your text with live highlighting, match list and flag toggles. Common-pattern dropdown.
Last updated
Frequently asked questions
- What is regex used for?
- Regex (regular expressions) lets you match patterns in text — like "any digit", "any word that starts with cat", or "a valid email". It's the standard tool for searching, validating and extracting structured text.
- How do I test a regex online?
- Paste your test text, type the pattern, set the flags, and matches highlight live. The match list below shows each match and any captured groups.
- What's the difference between greedy and lazy matching?
- Greedy quantifiers (* + ?) match as much as possible; lazy quantifiers (*? +? ??) match as little as possible. "<.+>" matches the whole "<a><b>"; "<.+?>" matches each tag separately.
- How do I match an email address with regex?
- Pick "Email" from the common-patterns dropdown for a sensible default, or use [^\s@]+@[^\s@]+\.[^\s@]+ for a permissive match. RFC-strict email regex is much longer — usually overkill.
- How do I match a URL with regex?
- Pick "URL" from the common-patterns dropdown. For most use cases https?:\/\/[^\s]+ is enough; for strict validation use a URL parser instead of regex.
- What do regex flags like i, g, m mean?
- i = case-insensitive, g = global (find every match, not just the first), m = multiline (^ and $ match line starts/ends), s = dotall (. matches newlines), u = unicode-aware.
- Why is my regex not matching?
- Common causes: missing g flag (only first match), unescaped special characters (. ? * + need backslashes when literal), and greedy/lazy mismatches. The error explainer flags syntax problems as you type.
- How do I escape special characters in regex?
- Prefix with a backslash: \. \? \* \+ \( \) \[ \] \{ \} \| \\ \/ \^ \$. To match a literal backslash inside a JavaScript string, you need \\\\ (four).
- Is regex the same in all languages?
- Mostly — the basics (character classes, quantifiers, groups) are universal. Subtle differences exist around lookbehind, named groups and Unicode handling. JavaScript regex (used here) is well documented on MDN.
- Can regex be slow on large text?
- Yes — "catastrophic backtracking" patterns (e.g. (a+)+) can hang on long inputs. If a pattern is slow, simplify it or break it into multiple smaller matches.