Test a regular expression
Test a JavaScript regular expression: matches highlighted as you type, capturing groups, replacement, no freeze on catastrophic backtracking.
Test a JavaScript regular expression: matches highlighted as you type, capturing groups, replacement, no freeze on catastrophic backtracking.
Runs entirely in your browser: nothing you type is sent or stored.
String.replace would give.
| Syntax | Matches |
|---|---|
. | |
\d, \w, \s | |
[abc], [^abc] | |
^, $ | |
*, +, ? | |
{2,4} | |
(…), (?<name>…), (?:…) | |
a|b | |
\b | |
(?=…), (?!…) |
g looks for every match, not only the first one.i ignores case, m makes ^ and $ work at each line, s lets the dot match line breaks.u reads the text as Unicode: an emoji is one character, and \p{L} matches a letter of any alphabet.y only matches at the current position, as a tokenizer does.$1, $2… insert the text of a numbered group, $<name> that of a named group.$& inserts the whole match, $$ a dollar sign.(a+)+$, on a long line of “a” ending with another letter, tries an exponential number of ways before failing. On a server, that blocks a process: a denial of service called ReDoS. Here the expression runs apart from the page and is stopped after a moment.
[^,]* to .*.