CodeCraft

Regex Tester

Test regular expressions in real time and view matches and capture groups.

//g
Flags:
Contact us at support@example.com or admin@devtools.io for help.
#1support@example.comindex: 14
Group 1: support
Group 2: example.com
#2admin@devtools.ioindex: 37
Group 1: admin
Group 2: devtools.io

How to Use

  1. Enter your pattern in the Regular Expression box (no leading/trailing / needed).
  2. Toggle flags as needed: g = global, i = case-insensitive, m = multiline, s = dotAll.
  3. Paste your test text in the Test String box — results update in real time.
  4. Yellow highlights show all matches. The list below shows capture groups for each match.

About Regular Expression Tester

Regular expressions (regex) are sequences of characters that define a search pattern. They are essential for text validation, parsing, and transformation in most programming languages. Key concepts include character classes ([a-z]), quantifiers (* + ? {}), anchors (^ $), groups (()), and flags (g for global, i for case-insensitive, m for multiline). This tester highlights all matches in real time as you type, helping you build and debug complex patterns immediately. Common use cases include email validation, URL extraction, log parsing, and data cleaning.

Use Cases

Form Validation

Test email, phone, URL patterns before implementing them in your application's validation logic.

Log Parsing

Build regex patterns to extract timestamps, error codes, or IPs from server log files.

Find & Replace

Prototype complex search-and-replace patterns with capture groups before running them on production data.

Data Extraction

Write patterns to scrape structured data from semi-structured text (CSV fields, HTML attributes, etc.).

Examples

Input
Pattern: \d{4}-\d{2}-\d{2}
Text: Today is 2024-01-15
Output
Match: 2024-01-15

\d{4} matches exactly 4 digits. The hyphen is a literal character between digit groups.

Input
Pattern: (\w+)@(\w+\.\w+)
Text: user@example.com
Output
Group 1: user
Group 2: example.com

Parentheses create capture groups. Group 1 captures the username, Group 2 the domain.

Common Pitfalls & Edge Cases

  • ⚠Greedy quantifiers (.* ) can match too much. Use lazy (.*?) or be more specific with character classes.
  • ⚠Backtracking in nested quantifiers like (a+)+ can cause catastrophic performance (ReDoS attacks).
  • ⚠JavaScript regex doesn't support lookbehind in all browsers. Check compatibility for (?<=...) patterns.
  • ⚠Remember to escape special characters: . * + ? ^ $ { } [ ] | ( ) \ when matching literals.

🔒 Data Privacy

Regex evaluation runs entirely in your browser's JavaScript engine. No text or patterns are sent to any server.

Standards & References

Frequently Asked Questions

Comments (0)

Leave a comment

0/2000