How to use Regex Tester
- 1. Enter a pattern. Write a JavaScript regular expression without surrounding slashes. Pick flags such as g, i, m, s, u, and y.
- 2. Add test text. Paste logs, HTML, or drop a file. Matches highlight in order; capture groups appear in the table.
- 3. Preview a replacement. Use `$1` and named groups in the replacement field to see the rewritten string instantly.
- 4. Grab a common pattern. The cheatsheet fills email, URL, IPv4, UUID, and hex color starting points — still review them before production.
About this tool
A regular expression is a compact language for describing sets of strings. JavaScript’s `RegExp` is based on the ECMAScript specification, which is close to (but not identical to) PCRE and Python’s `re`. The safest way to develop a pattern is against real examples: a tester that shows match spans and groups catches off-by-one errors long before the pattern hits production logs. PureDevKit uses the same engine as your browser, so what you see is what `String.prototype.matchAll` will do.
Flags that change meaning
`g` (global) finds every match instead of stopping at the first. `i` ignores case. `m` makes `^` and `$` match line boundaries. `s` lets `.` match newlines. `u` enables Unicode mode (needed for some property escapes). `y` is sticky: matching starts at `lastIndex`. Forgetting `g` in a replace is a classic bug: only the first occurrence changes. Using `g` with `^` can also surprise you because `^` still means start of string unless `m` is on.
Groups, named groups, and replace
Parentheses capture. `(?<name>...)` creates a named group available on `match.groups`. In replacements, `$1` is the first positional group and `$<name>` is a named group (ES2018). Non-capturing groups `(?:...)` keep precedence without polluting the group list. Greedy quantifiers (`*`, `+`) consume as much as possible; `*?` and `+?` are lazy. Catastrophic backtracking happens when nested quantifiers can fail in many ways against long non-matching input — keep patterns linear when they run on untrusted text.
JavaScript vs other engines
Lookbehind is supported in modern JS. Possessive quantifiers and some POSIX classes are not. `\d` in JS without the `u`/`v` flag is ASCII digits, not all Unicode digits. If you are porting a pattern from Python, Ruby, or grep, test it here rather than assuming identical syntax. For HTML or CSV, a regex is often the wrong parser; use a real parser when the grammar is nested.
Cheatsheet patterns are starting points
An email regex that is “good enough” for a UI hint is not RFC 5322. A URL regex will miss valid but unusual URLs. Use the cheatsheet to explore, then tighten the pattern to the domain you actually accept. When validating user input for security, prefer dedicated libraries and server-side checks over a single client regex.
Code examples
matchAll
const re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi;
for (const m of text.matchAll(re)) console.log(m[0], m.index);Named groups
const re = /(?<iso>\d{4}-\d{2}-\d{2})/g;
const m = re.exec(text);
console.log(m?.groups?.iso);Replace
text.replace(/\s+/g, " ").trim();