πŸ”

Regular Expression Tester

Test and debug regular expressions with live highlighting, capture groups, and match details. Supports all JavaScript regex flags (g, i, m, s, u).

Developer ToolsDevelopment
Loading tool...

How to Use Regular Expression Tester

What is a Regular Expression?

A regular expression (regex) is a pattern used to match character combinations in strings. Regex is incredibly powerful for validation, searching, extracting, and replacing text in programming.

Regex Syntax Basics

  • Literal characters: abc matches "abc" exactly
  • Character classes: [abc] matches a, b, or c; [0-9] matches any digit
  • Negated classes: [^abc] matches anything except a, b, or c
  • Quantifiers: * (0+), + (1+), ? (0 or 1), {n} (exactly n), {n,m} (between n and m)
  • Anchors: ^ (start of line), $ (end of line), \b (word boundary)
  • Groups: (abc) captures group, (?:abc) non-capturing group
  • Alternation: a|b matches a or b
  • Escape: \. matches literal dot (escape special chars with \)

How to Use This Tool

Test a Pattern

  1. Enter your regex pattern in the Pattern field (without / delimiters)
  2. Toggle flags as needed:
    • g (global): Find all matches, not just the first
    • i (case-insensitive): Match regardless of case
    • m (multiline): ^ and $ match line starts/ends
    • s (dotAll): . matches newlines too
    • u (unicode): Full unicode support
  3. Paste your test text in the Test Text area
  4. Click Run Test to execute the pattern
  5. View highlighted matches in the "Matches in Text" section
  6. See detailed match info including positions and captured groups

Example Patterns

  • Email: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b
  • URL: https?://[^\s]+
  • Phone (US): \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
  • Hex color: #[0-9A-Fa-f]{6}\b
  • Date (YYYY-MM-DD): \d{4}-\d{2}-\d{2}
  • IP Address: \b(?:\d{1,3}\.){3}\d{1,3}\b

Common Use Cases

  • Form Validation: Validate email, phone, password patterns in real-time
  • Data Extraction: Extract emails, URLs, dates, or IDs from logs or documents
  • Search & Replace: Find patterns in text files for bulk editing
  • Log Parsing: Extract error codes, timestamps, or user IDs from server logs
  • String Cleaning: Remove unwanted characters or normalize formats
  • Testing Regex: Debug patterns before implementing in code
  • Learning Regex: Experiment with patterns and see matches instantly

Understanding Flags

  • g (global): Without this, only the first match is found. With g, all matches are returned.
  • i (ignore case): hello matches "Hello", "HELLO", "hElLo", etc.
  • m (multiline): ^ matches start of each line, $ matches end of each line (not just start/end of entire string).
  • s (dotAll): Normally . doesn't match newlines. With s, it does.
  • u (unicode): Enables full unicode matching (important for emoji, accented characters, etc.).

Captured Groups

When you use parentheses () in your pattern, regex captures those parts:

  • Pattern: (\w+)@(\w+)\.(\w+)
  • Text: hello@example.com
  • Match: hello@example.com
  • Groups: $1 = hello, $2 = example, $3 = com

Use groups to extract specific parts of matches or for backreferences.

Tips

  • Start simple: Test with a basic pattern, then add complexity
  • Use \b for word boundaries: \bcat\b matches "cat" but not "catch"
  • Escape special characters: ., *, +, ?, [, ], {, }, (, ), ^, $, |, \ need \ before them to match literally
  • Test edge cases: Empty strings, very long strings, special characters
  • Use non-capturing groups (?:...) when you don't need to extract: Faster and cleaner
  • Avoid catastrophic backtracking: Patterns like (a+)+b can hang on long strings without matches

Frequently Asked Questions

Most Viewed Tools

πŸ“Ί

Screen Size Converter

710 views

Calculate screen width and height from diagonal size and aspect ratio. Convert between inches and centimeters for displays, TVs, and monitors with instant dimension calculations.

Use Tool β†’
πŸ–¨οΈ

DPI Calculator

290 views

Calculate DPI (dots per inch), image dimensions, and print sizes. Convert between pixels and physical dimensions for printing and displays.

Use Tool β†’
πŸ“„

Paper Size Converter

251 views

Convert between international paper sizes (A4, Letter, Legal) with dimensions in mm, cm, and inches. Compare ISO A/B series and North American paper standards.

Use Tool β†’
β›½

Fuel Consumption Converter

237 views

Convert between MPG (miles per gallon), L/100km (liters per 100 kilometers), and other fuel efficiency units. Compare car fuel economy across different measurement systems.

Use Tool β†’
βœ‚οΈ

CSV Splitter

226 views

Split large CSV files into smaller files by number of rows. Process large datasets in manageable chunks instantly.

Use Tool β†’
πŸ›οΈ

Product Schema Generator

206 views

Generate JSON-LD Product schema markup for SEO. Add product details like name, price, brand, rating, and availability to create structured data for rich search results.

Use Tool β†’
πŸ“„

Large Text File Viewer

175 views

View and search large text files up to 200MB in your browser. Features virtual scrolling, line numbers, search functionality, and file statistics. Perfect for log files, CSV, JSON, and code files.

Use Tool β†’
πŸ”‘

API Key Generator

162 views

Generate secure, cryptographically random API keys for authentication and authorization. Create custom API keys with various formats including hex, base64, and prefixed keys.

Use Tool β†’

Related Development Tools

Share Your Feedback

Help us improve this tool by sharing your experience

We will only use this to follow up on your feedback