Building a regular expression
A regular expression describes a text pattern: a date, an address, a reference number. Type the pattern and paste a sample: every match is highlighted, groups are underlined in color, and the list gives their content and position. The “Replace” section shows the transformed text, using $1 or $<name> to reuse a group.
Reading groups
Parentheses create a group: the part they cover is captured separately. In a date, three groups isolate the year, the month and the day, which the replacement puts back in whatever order you want. Name them with (?<year>…) to keep track of them, or write (?:…) when you only want to group.
Which flavor?
The tool uses your browser’s engine, and therefore JavaScript syntax. Most patterns also work in PHP, Python, Java or a text editor, but there are differences: character classes, lookbehinds, flags. Check in the target language before going to production.
Protected against catastrophic patterns
Some patterns, such as (a+)+, try a huge number of combinations when the text does not match. The search therefore runs separately, in a process that the tool stops after two seconds: the page stays usable. On a server, such a pattern can block a service: fix it.
Frequently asked questions
How do I search for a dot or a parenthesis?
Put a backslash before the character: \. searches for a dot, \( for a parenthesis, \\ for the backslash itself.
Why is there only one match?
Without the g flag, the search stops at the first match. Check it to get them all.
How do I match as little text as possible?
Quantifiers are greedy: <.+> swallows everything, from the first < to the last >. Add a question mark, <.+?>, to stop at the first one.
Is my text sent anywhere?
No. The search runs on your device. Only the selected options are saved, never the pattern or the text.