Regex Tester

Type a pattern, paste your text, and see matches highlighted with full match details. Runs entirely in your browser, nothing leaves your device.

Try:
//
Matches will be highlighted here.

How to use this

Type your pattern between the slashes, or click one of the preset buttons to start from a common pattern like an email or URL match. Adjust flags in the small box on the right, g for global or i for case-insensitive are the most common. Paste your text below and every match highlights instantly, with full details including each match's position and any capture groups shown underneath.

Flags, in plain terms

Flags change how the whole pattern behaves. The ones you will use constantly:

  • g (global): find every match, not just the first. Without it, a tester shows one result and stops.
  • i (case-insensitive): [a-z] also matches capital letters, so "error" finds "Error" and "ERROR".
  • m (multiline): ^ and $ match the start and end of each line instead of the whole text, which is what you want when testing against pasted log lines or lists.
  • s (dotAll): the dot also matches line breaks, so .* can span paragraphs.
  • u (unicode): treats the pattern as unicode-aware, which matters for text beyond plain ASCII.

A few patterns worth borrowing

These cover a large share of everyday validation and extraction jobs. Test them above against your own samples before trusting them in code:

  • Only digits: ^\d+$
  • A date as yyyy-mm-dd: ^\d{4}-\d{2}-\d{2}$ (checks the shape, not whether the date exists)
  • A hex colour: ^#?[0-9a-fA-F]{6}$
  • A URL slug: ^[a-z0-9]+(?:-[a-z0-9]+)*$
  • Any run of whitespace: \s+, the usual replacement target when you want to collapse spacing to a single space.

One honest warning: email addresses are the pattern everyone asks for and no short regex truly validates them. A loose check for text, an @ and a dot is fine for catching typos in a form; real confirmation is sending the address a message.

Frequently asked questions

Why does my pattern only find the first match?

Without the g (global) flag, a regular expression stops after the first match. Add g to see every match in the text.

How do I match a literal dot, dollar sign or bracket?

Those characters mean something special in a pattern, so escape them with a backslash: . matches a real full stop, $ a dollar sign and [ an opening bracket.

How do I test a regular expression here?

Type your pattern between the slashes, paste your text below, and every match highlights instantly. You can also start from a preset such as an email or URL pattern.

Which regex flags can I use?

Set flags in the small box next to the pattern. The most common are g (find all matches) and i (ignore upper and lower case).

Does it show capture groups and match positions?

Yes. Beneath the text you see full details for each match, including its position and any capture groups.

Is the text I test sent anywhere?

No. The tester runs entirely in your browser and nothing leaves your device.