Pikkola Regex, tool No. 13

Write the pattern. Watch it match.

Live highlights as you type, capture groups in a table, a replace simulator, twenty checked presets and a snippet for six languages. One page, and nothing leaves the tab.

Open the studio JavaScript RegExp
0
bytes sent
20
tested presets
6
languages
5
flags
Pattern

/ \b(\w+)@(\w+)\.\w{2,}\b /g

Text

write to [email protected]

or leave a note in [email protected]

2 matches, groups: hello / pikkola

Two addresses match, the rest of the line stays quiet, and the groups are read out below.

Studio

The pattern on the left, everything it does on the right

Matches light up as you type. Click a match to read its groups. The replace box uses the same expression, so what you try is what you copy.

Test text

Presets

Twenty patterns we ran before putting them here

Press one and it loads into the studio with a sample that should match and a line that should not. The Korean patterns are the ones we use at the desk.

Code

The same pattern in six languages

The snippet follows the pattern and flags above. Where an engine has no such feature, the comment says so rather than writing code that quietly fails.

Write a pattern above to see the snippet.

Flags: g is JavaScript only, Python and Go use inline or compiled flags, and Rust carries them inside the pattern.

Reference

Five flags, and what they change

Flag Name What it does
gglobalFind every match instead of stopping at the first.
iignore caseMatch letters without caring whether they are capitals.
mmultilineLet ^ and $ match at every line break, not only at the ends of the text.
sdot allLet . match a newline too.
uunicodeTreat the pattern as Unicode, so \p{L} and emoji work as one character.

Why this one

A tester should cost one tab, not an account.

The engine is the browser's.

A pattern that works here works in Node and in the browser console. There is no second dialect to learn, and no server round trip before a match appears.

The presets were run, not collected.

Each one comes with a sample it matches and a line it should not. A pattern that stops matching is visible immediately, which is the failure a copied pattern usually hides.

The code says what it cannot do.

Go and the Rust regex crate have no backreferences, and their named group syntax differs. The generated snippet says so instead of leaving you to find out in production.

No account. No upload. No pattern kept.

The pattern and the text live in the form. Closing the tab throws them away, which is the point when the text is a customer list or a log line.

Read the privacy note

Questions

Asked while the pattern is half typed

Is my pattern or text sent anywhere?

No. The pattern is compiled and run by the browser, and there is no request in the page at all. A content security policy blocks every other origin.

Which engine is this?

JavaScript RegExp, the same engine as Node and the browser console. It is not PCRE, Python or Go, and the code panel notes where they differ.

Why does my pattern work here and fail in Python?

Named groups are written (?<name>) in JavaScript and (?P<name>) in Python, and some escapes differ. Python has no global flag either, since findall repeats on its own. The generated snippet is written for the language you pick.

What happens with a huge text?

The match list stops at 10,000 and says so, and the status line reports how long the match took. A pattern that takes more than a moment gets a warning, because nested repeats can backtrack for minutes on a long line.

Can it replace?

Yes. The replace box uses $1 and $2 for groups, $& for the whole match and $<name> for a named group, and shows the result as you type. With the g flag every match is replaced, without it only the first.

Do the presets validate the numbers they find?

No. They find shapes. A Korean business number has a check digit and a resident number has one too, and a pattern cannot confirm either. Use them to find, then check the value with the issuing system.

What is the resident number preset for?

Masking. It keeps the birth date and the gender digit and replaces the remaining six, which is the form a support desk can paste into a ticket. Nothing you type leaves the tab.

Does it support lookbehind?

Current browsers support lookbehind and named groups. Go and the Rust regex crate do not support lookbehind or backreferences, and the code panel says so when you pick them.