DevLearningTools

TOOLS · REGEX

Test a regular expression, instantly.

Enter a pattern and some text to see every match highlighted live, processed entirely in your browser.

//g
Matches will be highlighted here

How This Tool Works

Type a pattern and some test text, and every match is highlighted live using JavaScript's native RegExp engine — the same engine your browser already runs. Toggle case-insensitive (i), multiline (m), dot-matches-newline (s), and unicode (u) flags to see how they change what matches.

If your pattern includes capture groups (parentheses), each match's captured values are listed separately below the highlighted text.

Write a pattern

e.g. \d+

Paste test text

the string to search

Engine scans it

JS's native RegExp, live

Matches highlighted

instantly, as you type

Try These Examples

Copy any pattern and test string below into the tool above to see it in action.

01

Find all numbers in a string

A plus sign after \d means "one or more digits" — this pulls out every number as its own match.

Pattern:  \d+
Test:     I have 42 apples and 7 oranges
Result:   highlights 42 and 7
02

Validate an email address

^ and $ anchor the match to the start and end of the whole string, so partial matches inside a longer line don't count.

Pattern:  ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
Test:     developer@example.com
Result:   the entire string matches
03

Case-insensitive matching

Without the i flag, "hello" only matches lowercase. Check the i box above and both instances light up.

Pattern:  hello
Test:     Hello World, hello there
Without "i": only the second "hello" matches
With "i":    both match
04

Pull out pieces with capture groups

Parentheses create capture groups — each one's matched value shows up separately below the highlighted text.

Pattern:  (\w+)@(\w+)\.com
Test:     contact me at test@example.com
Result:   $1=test  $2=example

Common Uses

  • Validating email addresses, phone numbers, or postal codes before accepting form input.
  • Searching log files for a specific pattern across many lines.
  • Extracting structured pieces of text, like dates or IDs, out of a larger string.
  • Testing a find-and-replace pattern before running it across real data.

Frequently Asked Questions

Which regex flavor does this use?

JavaScript's native RegExp syntax — the same engine that runs in Chrome, Firefox, Safari, and Node.js. Most patterns are portable to other languages, but some advanced features (like certain lookbehind support in older engines) can differ.

Why does my pattern show 0 matches even though it looks right?

Double-check your flags — case sensitivity (i) and multiline behavior (m) are common culprits. Also confirm special regex characters in your test text (like a literal dot or parenthesis) are actually meant to be matched literally, and escape them with a backslash if so.

Is my text or pattern sent anywhere?

No — matching runs entirely in your browser using JavaScript's built-in regex engine. Nothing is uploaded.