PublicSoftTools
Tools7 min read

Regex Tester Online Free — Test Regular Expressions Live

The free Regex Tester lets you write a regular expression and test it against any string in real time. Matches are highlighted as you type, with capture groups and index positions shown below. All JavaScript regex flags are supported — no signup, no server required.

How to Use the Regex Tester

  1. Open the Regex Tester.
  2. Enter your regular expression in the Pattern field.
  3. Select the flags you need (g, i, m, s, u).
  4. Paste or type your test string in the Test String area.
  5. Matches are highlighted live. Scroll down to see match details: index, length, and captured groups.

Regex Flags Reference

FlagNameEffect
gGlobalFind all matches, not just the first
iCase-insensitiveMatch regardless of letter case
mMultiline^ and $ match start/end of each line
sDotall. matches newline characters
uUnicodeTreat pattern and string as Unicode; required for emoji

Common Regex Patterns

Email address

A simple pattern that catches most valid email formats:

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

Use the i flag to make it case-insensitive. Note that a fully RFC-compliant email regex is much more complex — this pattern handles the common case.

URL

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

Matches http and https URLs. Use the g flag to find all URLs in a block of text.

Phone number (US format)

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

Matches formats like (555) 123-4567, 555-123-4567, and +1 555 123 4567.

IP address (IPv4)

\((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)\

Validates each octet is in the range 0–255.

Date (YYYY-MM-DD)

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

Matches ISO 8601 date format. Use the g flag to extract all dates from a document.

Capture Groups

Capture groups — defined with parentheses (…) — let you extract specific parts of a match. For example, to extract the domain from a URL:

https?:\/\/([\w.-]+)

Group 1 captures the domain. The tester shows each captured group separately below the main match list, along with its index position in the original string.

Named capture groups use the syntax (?<name>…):

(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})

Named groups are shown with their names in the match details, making them easier to identify when there are multiple groups.

Lookahead and Lookbehind

Lookahead (?=…) matches a position followed by a pattern without including it in the match. Lookbehind (?<=…) matches a position preceded by a pattern.

Example — match numbers followed by "px":

\d+(?=px)

This matches the digits in 16px and 24px but not in plain numbers. The px is not included in the match.

Debugging Regex That Isn't Matching

Test Regular Expressions Free Online

Live match highlighting, capture groups, all JS flags. No signup, browser-based.

Open Regex Tester