Skip to main contentSkip to navigationSkip to searchSkip to footer

How to Test Regex Online Free (Regex Tester with Real-Time Highlighting)

Learn how to test and debug regular expressions online free. Real-time match highlighting, flags explained (g, i, m, s), common patterns, capture groups, and performance tips.

NextUtils Team
8 min read
📚Tutorials
regexdeveloper-toolstext-toolspattern-matchingprogramming
Developer tools and pattern matching experts

Regular expressions are one of the most powerful tools in a developer's toolkit — and one of the most frustrating to debug. A single misplaced character can change what a pattern matches entirely, and without instant feedback it can take a long time to figure out why a regex is not working.

An online regex tester solves this by showing you matches in real time as you type. This guide covers how to use the free Regex Tester tool, how every major flag works, the most useful patterns with examples, capture groups, and tips to avoid common mistakes.

What is a regular expression?

A regular expression is a string of characters that defines a search pattern. The regex engine reads the pattern and applies it to a target string — finding matches, extracting groups, or replacing text.

Common uses for regex include: validating email addresses and phone numbers, extracting data from log files, find-and-replace in code editors, parsing URLs, sanitising user input, and routing in web frameworks.

How to test regex online

1

Open the Regex Tester

Go to the free Regex Tester — no sign-up needed. The tool uses JavaScript regex syntax, which matches Node.js, browser JavaScript, and TypeScript.

2

Enter your pattern

Type your regex pattern in the pattern field — without the surrounding slashes. For example, type \d{3}-\d{4} to match phone segments like 555-1234.

3

Set flags

Toggle the flags you need. Most patterns need the g flag to find all matches. Add i for case-insensitive matching. Add m if you are working with multiline text and need ^ and $ to match line boundaries.

4

Paste your test string

Enter the text you want to test against. Matches are highlighted in the test string in real time. Each match's position and capture group content appears in the match panel below.

5

Iterate and refine

Adjust the pattern based on what you see. The real-time feedback loop is far faster than running code repeatedly in a terminal or browser console.

Regex flags explained

FlagNameWhat it doesDefault
gGlobalFinds all matches, not just the firstOff
iCase-insensitiveTreats uppercase and lowercase as equivalentOff
mMultiline^ and $ match start/end of each line, not the whole stringOff
sDotAll. matches newline characters (\n)Off

Useful regex patterns with examples

Email address

[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}

Matches: alice@example.com, user.name+tag@domain.co.uk

URL

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b

Matches: https://example.com, http://sub.domain.org/path

Phone (US)

\(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}

Matches: 555-1234, (555) 867-5309, 555.123.4567

IPv4 address

\b(?:\d{1,3}\.){3}\d{1,3}\b

Matches: 192.168.1.1, 10.0.0.255

Date (YYYY-MM-DD)

\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])

Matches: 2026-03-24, 2025-12-31

How to use capture groups

Wrap part of a pattern in parentheses to create a capture group. The regex engine will return the content of each group alongside the full match — letting you extract specific parts of a matched string.

Pattern:  (\d{4})-(\d{2})-(\d{2})
Test:     2026-03-24
Group 1:  2026
Group 2:  03
Group 3:  24

Use (?:...) for a non-capturing group when you want to group without extracting, and (?<name>...) for a named capture group.

Frequently asked questions

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to match, find, replace, or validate strings in text. For example, the pattern \d{3}-\d{4} matches phone number segments like 555-1234.

What do regex flags do?

Flags modify how the regex engine matches. The g (global) flag finds all matches instead of stopping after the first. The i flag makes matching case-insensitive. The m (multiline) flag makes ^ and $ match line starts and ends. The s (dotAll) flag makes . match newline characters.

Why does my regex not match?

Common reasons: missing the g flag (pattern only matches the first occurrence), incorrect escaping (a literal dot needs \. not .), case sensitivity (add the i flag), anchoring issues (^ and $ without m flag), and greedy vs lazy quantifiers (use .*? instead of .* to match the shortest possible string).

What is the difference between .* and .*? ?

.* is greedy — it matches as many characters as possible. .*? is lazy (non-greedy) — it matches as few characters as possible. Given <a>text</a>, the pattern <.*> matches the entire string, while <.*?> matches just <a>.

How do I match a literal dot in regex?

In regex, . matches any character except a newline. To match a literal dot, escape it with a backslash: \. For example, to match a file extension like .txt, use \.txt — otherwise .txt would also match "atxt", "btxt", etc.

Is regex the same in all programming languages?

Core syntax is largely consistent across languages, but there are differences. The NextUtils regex tester uses JavaScript regex, which matches what you would use in browser JavaScript, Node.js, and TypeScript. Python, Java, and .NET have similar but not identical regex engines.

Test your regex pattern now

Free online regex tester with real-time highlighting, flag support, and match details. No sign-up, nothing stored.

Open Regex Tester →

Share this article

Related Articles

Continue exploring with these related posts

Ready to try our tools?

Explore our collection of free online tools for developers, designers, and power users.

Explore All Tools

Explore More Tools

Discover our collection of free online tools for developers, designers, and power users