← Back to Blog

How to Test Regex Online (With Live Matching)

Published on February 7, 2026

What Are Regular Expressions?

Regular expressions (regex or regexp) are patterns used to match character combinations in strings. They are one of the most powerful tools in a developer's toolkit — used for validation, searching, parsing, and text manipulation. Every major programming language supports regex, and they are used in editors, command-line tools, databases, and web frameworks.

Despite their power, regex has a reputation for being difficult to read and write. A pattern like ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ is perfectly valid (it matches IPv4 addresses), but reading it cold requires significant mental effort. This is where a visual regex tester becomes invaluable.

Regex Basics

Here are the fundamental building blocks of regular expressions:

.       — Matches any single character (except newline)
\d      — Matches any digit [0-9]
\w      — Matches any word character [a-zA-Z0-9_]
\s      — Matches any whitespace character
^       — Matches the start of a string
$       — Matches the end of a string
*       — Matches 0 or more of the preceding element
+       — Matches 1 or more of the preceding element
?       — Matches 0 or 1 of the preceding element
{n,m}   — Matches between n and m of the preceding element
[abc]   — Matches any character in the set
[^abc]  — Matches any character NOT in the set
(...)   — Capture group
|       — Alternation (OR)

Common Regex Patterns

Email Validation

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

This pattern matches standard email addresses. It checks for one or more valid characters before the @, a domain name, and a top-level domain of at least two characters.

URL Matching

https?:\/\/[\w\-]+(\.[\w\-]+)+[\/\w\-._~:?#[\]@!$&'()*+,;=%]*

Matches HTTP and HTTPS URLs with various path and query components.

Phone Numbers (US)

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

Matches US phone numbers in formats like (555) 123-4567, 555-123-4567, +1 555 123 4567, and more.

Regex Flags

Flags modify how the regex engine processes the pattern. The most commonly used flags are:

g — Global: find all matches, not just the first
i — Case-insensitive matching
m — Multiline: ^ and $ match line boundaries, not just string boundaries
s — Dotall: . matches newline characters too
u — Unicode: enables full Unicode matching

For example, /hello/gi matches "hello", "Hello", "HELLO", and every other case variation, finding all occurrences in the text.

Capture Groups

Parentheses create capture groups that let you extract specific parts of a match. This is one of the most powerful features of regex:

// Pattern: (\d{4})-(\d{2})-(\d{2})
// Input:   2026-02-07
// Group 1: 2026 (year)
// Group 2: 02   (month)
// Group 3: 07   (day)

// Named groups (modern syntax):
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})

Non-capturing groups (?:...) group without capturing, which is useful when you need grouping for alternation or quantifiers but do not need to extract the matched text.

How to Use the PulpMiner Regex Tester

The Regex Tester provides real-time feedback as you build patterns:

  1. Enter your regex pattern in the pattern field.
  2. Set flags — toggle global, case-insensitive, multiline, and other flags.
  3. Paste your test string — matches are highlighted in real time as you type.
  4. Inspect capture groups — each match shows its captured groups with their content and position.

Practical Examples

Here are some practical regex patterns you can test right away:

// Extract all hashtags from text
#[a-zA-Z0-9_]+

// Find duplicate words
\b(\w+)\s+\1\b

// Match HTML tags
<([a-z][a-z0-9]*)\b[^>]*>

// Validate hex color codes
^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$

Building regex incrementally — testing each piece as you add it — is far more effective than trying to write the whole pattern at once. The real-time highlighting makes this iterative process fast and intuitive. Try the Regex Tester to build and debug your patterns.

Need to extract data from websites?

PulpMiner turns any webpage into a structured JSON API. No scraping code needed — just point, click, and get clean data.

Try PulpMiner Free

No credit card required