Regular Expression

//g

Test String

Common Patterns

Regex Cheat Sheet

Characters

. Any character (except newline)
\d Digit [0-9]
\w Word char [a-zA-Z0-9_]
\s Whitespace
\b Word boundary
[abc] Character class
[^abc] Negated class

Quantifiers

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

Groups & Anchors

(abc) Capture group
(?:abc) Non-capturing group
(?<name>abc) Named group
a|b Alternation (OR)
^ Start of string/line
$ End of string/line

About Regular Expressions

Regular expressions (regex) are powerful patterns used to search, match, and manipulate text. They are supported by virtually every programming language and are essential for text processing, data validation, log analysis, and web scraping.

Real-time match highlighting
Capture group display
Find & replace with backreferences
100% client-side processing

Complete Guide to Regular Expressions

Free Online Regex Tester

Our regex tester lets you write, test, and debug regular expressions with instant visual feedback. Matches are highlighted in the test string in real time, with detailed information about each match including index, length, and capture groups. Whether you're validating email addresses, parsing log files, or extracting data — this tool gives you immediate, actionable results.

What Are Regular Expressions?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Originally developed in formal language theory in the 1950s, regex has become an indispensable tool in computing. It is used to match, search, extract, and replace text based on patterns rather than literal strings.

For example, the pattern \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b matches email addresses, while ^\d{4}-\d{2}-\d{2}$ validates dates in YYYY-MM-DD format.

Regex Syntax Elements

🔤 Character Classes

  • . — Matches any character (except newline)
  • \d — Matches any digit [0-9]
  • \w — Matches word characters [a-zA-Z0-9_]
  • \s — Matches whitespace (space, tab, newline)
  • [abc] — Matches any character in the set
  • [^abc] — Matches any character NOT in the set

🔢 Quantifiers

  • * — Zero or more times
  • + — One or more times
  • ? — Zero or one time
  • {n} — Exactly n times
  • {n,m} — Between n and m times
  • *? / +? — Lazy (non-greedy) versions

📎 Groups & References

  • (abc) — Capturing group
  • (?:abc) — Non-capturing group
  • (?<name>abc) — Named capturing group
  • \1 — Backreference to group 1
  • a|b — Alternation (a OR b)

⚓ Anchors & Boundaries

  • ^ — Start of string (or line with m flag)
  • $ — End of string (or line with m flag)
  • \b — Word boundary
  • \B — Non-word boundary
  • (?=abc) — Positive lookahead
  • (?!abc) — Negative lookahead

JavaScript Regex Flags

FlagNameDescription
gGlobalFind all matches, not just the first one
iCase InsensitiveMatch regardless of letter case
mMultiline^ and $ match start/end of each line
sDotall (Single Line). matches newline characters too
uUnicodeEnable full Unicode matching

How to Use the Regex Tester

  1. Enter a Pattern: Type your regular expression in the pattern input field. The tool uses JavaScript regex syntax.
  2. Set Flags: Toggle flags like global (g), case-insensitive (i), multiline (m), dotall (s), and unicode (u) to control matching behavior.
  3. Add Test Text: Type or paste text into the test string area, or load the built-in sample text.
  4. View Matches: Matches are highlighted in real time. Detailed results show each match with index, length, and capture groups.
  5. Replace Mode: Enable replace mode to perform regex-based find-and-replace with backreference support ($1, $2, etc.).
  6. Use Presets: Click common patterns like Email, URL, IP Address, or Phone to quickly load tested patterns.

Common Use Cases for Regex

Form Validation: Regex is widely used to validate user input on web forms — email addresses, phone numbers, postal codes, credit card numbers, dates, and more. Proper validation patterns prevent malformed data from entering your system.

Log Analysis: System administrators and DevOps engineers use regex to parse and filter log files. Patterns can extract timestamps, error codes, IP addresses, and request paths from massive log datasets.

Data Extraction & Web Scraping: Regex helps extract structured data from unstructured text — pulling prices from product pages, extracting links from HTML, or parsing CSV files with irregular formatting.

Search & Replace in Code Editors: Most code editors (VS Code, Sublime Text, IntelliJ) support regex in find-and-replace. This enables powerful refactoring like renaming variables, changing function signatures, or reformatting code.

URL Routing: Web frameworks like Express.js, Django, and Rails use regex patterns to define URL routes, matching request paths to controller actions with parameter extraction.

Data Cleaning: Clean and normalize messy datasets by removing extra whitespace, standardizing phone number formats, stripping HTML tags, or converting date formats with regex replace operations.

Why Use Our Regex Tester?

Instant Visual Feedback: Matches are highlighted in your test string as you type the pattern. No need to submit a form or click a button.

Complete Match Details: See every match with its index, length, capture groups, and named groups — all in a clean, organized interface.

Replace Mode:Test find-and-replace operations with full backreference support ($1, $2, $&, etc.) before applying them in your code.

Built-in Pattern Library: Quickly load common patterns for emails, URLs, IP addresses, dates, hex colors, HTML tags, and phone numbers.

Cheat Sheet: A comprehensive regex reference is built right into the tool so you never need to leave the page.

100% Privacy: All regex processing happens in your browser. No data is sent to any server. Your patterns and test strings stay completely private.

Perfect For

  • Web developers validating forms
  • Backend developers parsing data
  • DevOps engineers analyzing logs
  • Data scientists cleaning datasets
  • QA testers writing test patterns
  • Students learning regex
  • System administrators filtering logs
  • Security analysts detecting patterns
  • Content editors doing bulk text changes
  • API developers validating payloads
  • SEO professionals parsing URLs
  • Anyone working with text patterns

🔒 100% Privacy Guaranteed

All regex processing is performed entirely in your web browser using JavaScript. Your patterns, test strings, and replace operations are never uploaded to our servers, stored in databases, logged, or transmitted to any third party. Everything happens locally on your device.