TOOL 02
Regex tester
Write a pattern, paste the text it must survive, and see every match with its index and capture groups.
Pattern and sample text
JavaScript syntax. The global flag is added automatically so every match is listed.
Flags change the question
g finds every match instead of stopping at the first. i makes matching case-insensitive. m changes ^ and $ to match at line boundaries rather than only at the start and end of the whole string. s lets . match newlines. u enables Unicode mode, which is required for properties like \p{L}.
Greedy, lazy and catastrophic
Quantifiers are greedy by default: a+ takes as much as it can and backtracks until the rest of the pattern fits. Adding ? makes it lazy. Backtracking is where regex engines become slow: a nested quantifier such as (a+)+ against a long non-matching string can take exponential time. If a pattern is slow on 30 characters, it will hang on 300.
Lookbehind and named groups
Modern JavaScript supports lookbehind (?<=…) and named groups (?<name>…). Older runtimes and some embedded engines do not. If a pattern works here but fails in production, check the engine version before rewriting the pattern.
Escaping in strings
A regex written in JavaScript source needs its backslashes doubled inside a string literal, or use a regex literal. The most common "my pattern works in the tester but not in code" bug is a lost backslash.
Questions
Why is the global flag forced on?
So the tester lists every match rather than only the first. Remove it in your own code if you only need a boolean test.
Does it support lookbehind?
Yes on current browsers; no on older Safari and many embedded engines. The tester uses the engine that will run your page.
What does an empty match mean?
A pattern such as a* can match zero characters. The tester advances the index to avoid an infinite loop and shows the empty match explicitly.
Can I test against a file?
No uploads. Paste the relevant lines; for large logs, test a representative sample first.