Map Extract
Free tool

Regular expression tester

Write a pattern, paste some text and see every match with where it starts and what each capture group caught. Add a replacement to preview a find and replace, using $1, $2 and so on to reuse groups.

Runs in your browser. Nothing you enter is uploaded.

Testing a pattern

  1. Enter the pattern

    Type it without surrounding slashes. The page opens with a UK postcode pattern as a starting point.

  2. Set the flags

    g finds every match rather than the first, i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks, u turns on full Unicode and y matches only at the current position.

  3. Paste the test text

    Use real examples, including ones that should not match. The match count updates as you type, and a mistake in the pattern shows the browser's own error message.

  4. Read the match table

    Each row gives the match number, the matched text, its position in the text and the value of every capture group.

  5. Try a replacement

    Type a replacement such as $1 $2 and the text after replacement appears below, so you can check a clean-up before running it in a spreadsheet or script.

Example: pulling UK phone numbers out of pasted text

A list of contact details copied from several websites (all numbers are Ofcom drama numbers) mixes landlines, a mobile and an international format. A pattern that accepts either +44 or a leading 0, then three groups of digits, finds all four. The replacement wraps each in brackets without its prefix, showing what each group captured.

The test also reveals a limit worth knowing: the mobile number is split 7700, 900, 123 rather than the usual 07700 900123, because the pattern does not know UK number layouts. For storing numbers, normalise them to +44 form rather than relying on how they were written.

Input
Pattern: (?:\+44\s?|0)(\d{2,4})\s?(\d{3,4})\s?(\d{3,4})   Flags: g
Text: Ring 0113 496 0000 or 07700 900123, fax 0161 496 0999. Office: +44 20 7946 0000.
Replace with: [$1 $2 $3]
Result
4 matches
1  0113 496 0000      at 5    $1=113  $2=496  $3=0000
2  07700 900123       at 22   $1=7700  $2=900  $3=123
3  0161 496 0999      at 40   $1=161  $2=496  $3=0999
4  +44 20 7946 0000   at 63   $1=20  $2=7946  $3=0000
After replacement: Ring [113 496 0000] or [7700 900 123], fax [161 496 0999]. Office: [20 7946 0000].

Building blocks you will use most

TokenMatches
\d, \w, \sA digit, a word character, a whitespace character
[A-Z], [^@]Any one of a set, or anything except a set
?, *, +, {2,4}Optional, any number, one or more, between two and four
( ), (?: )A capture group, or a group that does not capture
^, $, \bStart, end, a word boundary
a|bEither a or b

Questions people ask

Which regex flavour does this use?

It uses your browser's JavaScript regular expression engine, so the syntax matches what you would write in JavaScript and in the many no-code and automation tools built on it. Lookbehind, named groups and Unicode classes work in current browsers. Patterns written for PCRE, Python or .NET usually work with small changes; spreadsheet regex functions often support less.

Why does my pattern only find one match?

Without the g flag, a JavaScript regular expression stops at the first match. Add g to the flags box to find every match in the text. For text spread over several lines where you use ^ or $, add m as well.

How do I match an email address with regex?

A practical pattern such as [\w.+-]+@[\w-]+(\.[\w-]+)+ finds most addresses in ordinary text. No short pattern covers every address the email standards allow, and none can tell you whether a mailbox exists. For lead lists, extract with a pattern, then check the addresses with an email verifier.

What do $1 and $2 mean in the replacement?

They insert whatever the first and second capture groups matched. $& inserts the whole match. That lets you reorder or reformat parts of the text, for example turning YO17HH into YO1 7HH with a postcode pattern and the replacement $1 $2.

Where your data goes

Patterns are run on this page by your browser. The text you test, which may include contact details, is not sent to Map Extract or anywhere else.

Checked against the tool on

Top