Naar de hoofdinhoud
Tools Star Hub

Regex-tester

Test een reguliere expressie op voorbeeldtekst en zie elke overeenkomst, de positie en de groepen.

Tool laden…

Deze tool werkt in je browser. Invoer, bestanden en gegenereerde waarden blijven op dit apparaat. Favorieten en recent gebruikte tools bewaren, als je ze gebruikt, alleen toolnamen in de lokale opslag — nooit wachtwoorden, documenten of QR-inhoud. Lees het privacybeleid.

De uitgebreide handleiding voor deze tool (gebruik, voorbeelden en veelgestelde vragen) is voorlopig in het Engels.

What this tool does

Type a regular expression, choose flags, and paste the text you want to test. The page lists whether anything matched, how many matches it found, the matched text, where each match starts, and any capture groups.

How to use

  1. Enter the pattern without surrounding slashes.
  2. Turn on the flags you need. g finds every match. i ignores case. m changes ^ and $. s lets a dot match a line break. u turns on Unicode mode.
  3. Paste the test text.
  4. Press Test expression. An invalid pattern shows the browser’s syntax message.

Examples

  • Find amounts

    Pattern \d+, flag g, text “Order 14 and order 3”. You get two matches, 14 at the first digit and 3 at the later digit.

  • Capture a name

    Pattern Name: (\w+) on “Name: Sara” shows the full match and group 1 as Sara.

Main features

  • Match count, matched text, and the character index where each match starts.
  • Numbered groups and named groups when the pattern has them.
  • A stop after 50 matches so a huge result does not fill the page.

How it works

The page builds a JavaScript RegExp and runs it on the text you pasted. It does not eval the pattern as a script. A dot matches one character. * means zero or more, + means one or more, and ? means optional. Brackets match one character from a set. Parentheses capture a group. A bar means or. \d is a digit, \s is whitespace, and \w is a word character. Without g, only the first match is listed.

Tips

  • Test a small sample before you use the same pattern in code.
  • If the pattern can match an empty string, the tester still moves forward so it does not loop forever. You will see an empty match when that happens.

Limitations

This uses the browser’s JavaScript regular expressions, which differ from some other engines. A pattern longer than 300 characters is rejected. A very slow pattern can still stall the tab. The page does not sandbox the match in a separate process. It will not run other JavaScript you type in the pattern box.

See the disclaimer for what these tools do not cover.

FAQ

Why do I only see one match?
Turn on the g flag. Without it, the result stops after the first match.
Does this execute code from the pattern?
No. The pattern is passed to the RegExp constructor. It is not evaluated as a program.
Is my input sent to a server?
No. The pattern and the sample text are tested in this tab. They are not uploaded.
What does the g flag do in a regex?
The g (global) flag finds every match instead of stopping at the first one. Without it, only the first match is shown.
What is a capture group?
Parentheses in a pattern create a capture group, which saves the part of the match inside them. (\d{4})-(\d{2}) captures the year and the month separately.