1. Home
  2. Developer & Security
  3. Regex Tester

Regex Tester

Write a pattern and test it instantly: every match highlighted, a table of capture groups, a replacement preview and a library of common ready-made patterns.

100% freeRuns in your browserNo sign-up
//
Quick reference
.Any character\dDigit
\wLetter, digit or _\sWhitespace
^ $Line start/end\bWord boundary
* + ?0+ / 1+ / optional{2,5}2 to 5 times
[abc]One of(…)Capture group
a|bOr(?=…)Lookahead

What are regular expressions?

Regular expressions (regex) are a compact language for describing text patterns. They let you search, replace and validate complex structures in a single line. Nearly every programming language supports them — JavaScript, Python, PHP, Java — as do editors and command-line tools. Typical uses: validating emails and phone numbers, extracting data from text, and cleaning files.

How to use the tester

  1. Type your pattern without the surrounding slashes.
  2. Add flags: g for all matches, i to ignore case, m for multiline, s so dot matches newlines, u for Unicode.
  3. Enter a test string and watch matches highlight instantly.
  4. Check the match table for each match's index and captured groups.
  5. Enter a replacement using $1, $2 for groups — like the example that reformats dates.

Working with Unicode

In JavaScript, \w only matches ASCII letters, digits and underscore. For letters in any language use \p{L} with the u flag, or a script range such as [\u0600-\u06FF] for Arabic. Likewise, \b only understands ASCII words; use lookarounds like (?<!\p{L}) for Unicode-aware boundaries.

Handy patterns

  • US ZIP code: ^\d{5}(-\d{4})?$
  • UK postcode (simplified): ^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$
  • Strong password (8+, upper, lower, digit): ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$
  • Hex color: ^#(?:[0-9a-fA-F]{3}){1,2}$

To apply a replacement across a long text, use Find & Replace, which supports regex too.

Quick regex cheat sheet

TokenMeaning
.Any character except newline
\d / \w / \sDigit / letter, digit or _ / whitespace
* / + / ?Zero or more / one or more / optional
{2,5}Between 2 and 5 times
^ / $Start / end of line
[a-z] / [^0-9]Character set / anything but digits
( ) / |Capture group / alternation

Regex with non-Latin text

In JavaScript, \w matches only Latin letters. To match Arabic, use the range [\u0600-\u06FF] or the Unicode property \p{Script=Arabic} with the u flag. Diacritics are separate characters, so you may want to strip them first with Remove Tashkeel.

Frequently Asked Questions

Which regex engine is used?

Your browser's built-in JavaScript engine — largely compatible with other languages, with minor differences in advanced features.

Why doesn't \w match accented or Arabic letters?

In JavaScript \w is ASCII-only. Use \p{L} with the u flag.

What does the g flag do?

It finds every match instead of stopping at the first.

How do I reference a group in the replacement?

Use $1 for the first group, $2 for the second, or $ for named groups.

Is my text sent to a server?

No. Everything runs in your browser.

Last updated: