← All Articles Β· Β· 6 min read

Regex Tester Tool: Test and Debug Regular Expressions Online

How to use a regex tester tool to write, test, and debug regular expressions. Includes a guide to regex syntax, common patterns, and tips for avoiding common mistakes.

regexregular-expressionsdeveloper-toolsonline-toolsdebugging

Regex Tester Tool: Test and Debug Regular Expressions Online

Regular expressions are powerful but unforgiving. A misplaced . or missing escape changes everything. A good regex tester tool lets you see matches in real time, understand what your pattern is doing, and catch mistakes before they reach production.


Best Free Regex Tester Tool

DevPlaybook Regex Tester β€” test your regex against multiple strings simultaneously, see matches highlighted, and inspect capture groups.

Key features:

  • Live match highlighting as you type
  • Capture group visualization
  • Flag toggles (global, case-insensitive, multiline, dotAll)
  • Reference panel with common patterns
  • No account required

How to Test Regex Online

  1. Enter your pattern (without / delimiters)
  2. Set flags as needed (g for all matches, i for case-insensitive)
  3. Paste your test strings
  4. See matches highlighted in real time

Example: Testing an email pattern

Pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Flags: i (case-insensitive)

Test strings:
[email protected]      βœ“ match
not-an-email           βœ— no match
[email protected]      βœ“ match
@nodomain.com          βœ— no match

Regex Syntax Quick Reference

Character Classes

PatternMatches
.Any character except newline
\dDigit (0-9)
\DNon-digit
\wWord character (a-z, A-Z, 0-9, _)
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Any of: a, b, c
[^abc]Not any of: a, b, c
[a-z]Range: a through z

Quantifiers

PatternMeaning
*0 or more
+1 or more
?0 or 1 (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?0 or more (non-greedy)
+?1 or more (non-greedy)

Anchors

PatternMeaning
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNot a word boundary

Groups

PatternMeaning
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind

Common Regex Patterns for Developers

Email Validation

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

Note: This is a reasonable practical check, not RFC 5322 compliant. The full spec is extraordinarily complex.

URL

https?://[^\s/$.?#].[^\s]*

Or more precisely:

^(https?|ftp)://[^\s/$.?#].[^\s]*$

IP Address (IPv4)

^(\d{1,3}\.){3}\d{1,3}$

Strict version (validates 0-255 range):

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

Phone Number (US)

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

Date (YYYY-MM-DD)

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

UUID

^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$

Case-insensitive version:

^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$

Credit Card (basic format check)

^4[0-9]{12}(?:[0-9]{3})?$        # Visa
^5[1-5][0-9]{14}$                 # Mastercard
^3[47][0-9]{13}$                  # Amex

HTML Tag Stripping

<[^>]*>

Replace matches with empty string to remove tags. (For real HTML parsing, use a proper parser β€” regex has well-known limitations with nested structures.)

Hex Color

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

Semantic Version

^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$

Regex Flags Explained

Flags modify how the pattern matches:

FlagCodeEffect
GlobalgFind all matches (not just first)
Case insensitivei[a-z] matches upper and lower case
Multilinem^ and $ match line boundaries, not just string boundaries
Dot alls. matches newlines too
UnicodeuEnable Unicode support, proper emoji/Unicode matching
// JavaScript
const re = /pattern/gi;  // global, case-insensitive

// Using RegExp constructor
const re2 = new RegExp('pattern', 'gi');

Common Regex Mistakes

1. Not Escaping Special Characters

These characters have special meaning in regex: . * + ? ^ $ { } [ ] | ( ) \

To match them literally, escape with \:

Pattern to match "1.5":    1\.5   (not 1.5, which matches "1X5" too)
Pattern to match "(":      \(
Pattern to match "$":      \$

2. Greedy vs Non-Greedy

Greedy quantifiers match as much as possible:

Pattern: <.+>
String:  <a>hello</a>
Match:   <a>hello</a>  (greedy: takes the whole thing)

Non-greedy (? after quantifier) matches as little as possible:

Pattern: <.+?>
String:  <a>hello</a>
Matches: <a> and </a>  (non-greedy: stops at first >)

3. ^ Inside Character Classes

^ at the start of a character class negates it:

[abc]   matches a, b, or c
[^abc]  matches anything EXCEPT a, b, or c

Outside character classes, ^ anchors to start of string.

4. . Doesn’t Match Newlines by Default

// Doesn't match across newlines
/start.+end/.test('start\nend')  // false

// Use dotAll flag to match newlines
/start.+end/s.test('start\nend')  // true

// Or use [\s\S] to match everything including newlines
/start[\s\S]+end/.test('start\nend')  // true

5. Catastrophic Backtracking

Some patterns can cause exponential slowdown on certain inputs:

Dangerous pattern: (a+)+
Input: "aaaaaaaaaaaaaaaaab"
Result: engine tries exponentially many combinations before giving up

Avoid nested quantifiers on overlapping character classes.


Regex in Different Languages

The core syntax is consistent, but details vary:

JavaScript:

const match = 'hello'.match(/h(e)llo/);
const replaced = 'hello world'.replace(/world/, 'there');
const found = /^\d+$/.test('123');

Python:

import re
match = re.search(r'h(e)llo', 'hello')
replaced = re.sub(r'world', 'there', 'hello world')
found = bool(re.match(r'^\d+$', '123'))

Go:

import "regexp"
re := regexp.MustCompile(`h(e)llo`)
match := re.FindString("hello")

When Not to Use Regex

Regex is not always the right tool:

  • Parsing HTML/XML β€” use a proper DOM parser (BeautifulSoup, cheerio, etc.)
  • Validating emails β€œproperly” β€” the full RFC spec is not practical to regex
  • Parsing deeply nested structures β€” use a parser generator or library
  • Lexing/parsing programming languages β€” regex can handle tokens but not grammar

Regex is best for: search, simple validation, transformation of well-defined string formats.


Practice

The best way to learn regex is to test real patterns against real data. Use DevPlaybook Regex Tester to experiment β€” it shows live matches, capture groups, and has a quick-reference panel built in.

Start with simple patterns, add complexity one piece at a time, and always test against edge cases (empty strings, Unicode characters, very long inputs).

Free Newsletter

Level Up Your Dev Workflow

Get new tools, guides, and productivity tips delivered to your inbox.

Plus: grab the free Developer Productivity Checklist when you subscribe.

Found this guide useful? Check out our free developer tools.