🔍 Regex Tester

Write, test, and debug regular expressions with live match highlighting, group capture, and find-and-replace — entirely in your browser.

PATTERNS:
//
TEST STRING

About Regex Tester

Regular expressions (regex) are patterns used to search, match, extract, and transform text. They are built into virtually every programming language — JavaScript, Python, Java, Go, Ruby — and are indispensable for input validation, log parsing, data extraction, and text processing. Writing a correct regex and testing it against real data is notoriously tricky, which is why a live tester that shows matches as you type is such a useful tool.

This browser-based regex tester highlights all matches in your test text in real-time, shows every capture group for each match, and supports find-and-replace with backreferences. It also includes 16 pre-built patterns for common Indian and international formats — email, phone, PAN card, Aadhaar, IFSC code, IPv4/IPv6, URL, date, time, hex colour, credit card, JWT, UUID, and HTML tags. All processing is entirely client-side.

How to test a regular expression

  1. Enter your regex pattern in the Pattern field (without the surrounding slashes).
  2. Toggle the flags you need: g (global — find all matches), i (case-insensitive), m (multiline), s (dot matches newline), u (unicode).
  3. Type or paste your test text. Matches highlight immediately.
  4. Expand any match in the list to inspect its capture groups.
  5. Switch to Replace mode, enter a replacement string using $1, $2, or named group references ($<name>), and see the result instantly.
  6. Or click a Common Pattern to load a ready-made regex for email, phone, PAN, UUID, and more.

Features

🔍 Live matching

All matches highlight in real-time as you type your regex — no submit button needed. Each match is listed with its index and matched text.

🎯 Capture groups

Expand any match to see all numbered and named capture groups. Named groups (?<name>...) are shown by their name for clarity.

⇄ Find & Replace

Switch to Replace mode, enter a replacement with $1 $2 backreferences or named group refs, and see the full substituted output.

🚩 Regex flags

Toggle g (global), i (case-insensitive), m (multiline — ^ and $ match line boundaries), s (dot-all), and u (full unicode) with one click.

📋 Common patterns

16 ready-made patterns: Email, Indian Phone, PAN, Aadhaar, IFSC, IPv4, IPv6, URL, Date, Time, Hex color, Credit card, JWT, UUID, HTML tag.

🛡️ Privacy

100% client-side using the browser's native RegExp engine. Your test strings and patterns never leave your browser.

Frequently Asked Questions

What regex flavour does this tester use?

It uses JavaScript's built-in RegExp engine (ECMAScript regex). This is the same engine used in browsers and Node.js. It supports lookahead and lookbehind assertions, named capture groups, Unicode property escapes (with the u flag), and the s (dotAll) flag. It does not support atomic groups or possessive quantifiers, which are PCRE-only features.

How do I use named capture groups?

Named groups use the syntax (?<name>pattern). For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) matches a date and captures three named groups. In the match list, named groups appear by name. In replace mode, reference them as $<year>, $<month>, $<day>.

Why is my regex matching too much (greedy)?

By default, quantifiers like *, +, and {n,m} are greedy — they match as much as possible. Add a ? after the quantifier to make it lazy (minimal): .* becomes .*?, .+ becomes .+?. Lazy quantifiers match as little as possible, which is usually what you want when parsing structured text.

What does the 'm' (multiline) flag do?

Without m, ^ matches only the start of the entire string and $ matches only the end. With m enabled, ^ matches the start of each line and $ matches the end of each line. This is essential when processing multi-line text and wanting to match per-line patterns.

How do I match a literal dot, bracket, or other special character?

Special regex characters (. * + ? ^ $ { } [ ] | ( ) \) must be escaped with a backslash to match literally. For example, to match a literal dot use \., to match a literal parenthesis use \(, and to match a backslash itself use \\.

Regex tester guide: write, test, and understand regular expressions

Regular expressions are one of the most powerful and misunderstood tools in a developer's toolkit. A well-written regex can replace dozens of lines of string parsing code. A poorly written one can silently match the wrong input, miss edge cases, or introduce catastrophic backtracking that locks up a server under high load.

Braxik's regex tester lets you write a pattern, paste test input, and see exactly which parts of the input are matched, which capturing groups contain, and how the engine interprets your pattern. Testing against realistic examples — including inputs that should not match — is the most reliable way to catch mistakes before they reach production.

The tester supports JavaScript regex syntax with all standard flags: g (global, find all matches), i (case-insensitive), m (multiline, ^ and $ match line boundaries), s (dotAll, dot matches newline), and u (Unicode). Most regex syntax is compatible across languages, but there are important differences between JavaScript, Java, Python, and PCRE regex engines that you should verify in your target environment.

One of the most common regex bugs is a pattern that matches slightly more or less than intended because of greedy vs lazy quantifiers, missing anchors, or an incomplete character class. This tester makes those issues visible by highlighting exactly what was captured, so you can refine the pattern iteratively.

How it works

The tester compiles your regex pattern using the browser's built-in RegExp engine, which implements the ECMAScript regex specification. It then executes the regex against the test input and collects all match objects (with the global flag) or the first match object (without it). Each match object contains the full match, the position, and the contents of any capturing groups.

Match highlighting works by splitting the input text around each match and wrapping the matched portions in coloured span elements. Different capturing groups are optionally highlighted in different colours to make it easy to see which group captured which part of the input.

The regex details panel shows the current pattern broken down by token where possible, explaining what each part means. This is especially helpful for learning regex syntax or for reviewing patterns written by someone else.

Common uses

  • Validate emails, phone numbers, postcodes, PAN cards, Aadhaar numbers, GST registration numbers, or internal ticket reference formats.
  • Extract fields from application logs — timestamps, log levels, thread names, exception types — before writing a production log parser.
  • Test named and numbered capturing groups before using them in replacement logic or Java Matcher group() calls.
  • Build and test URL patterns for router configuration in React Router, Spring MVC @RequestMapping, or nginx location blocks.
  • Validate and extract date strings in multiple formats (dd/MM/yyyy, yyyy-MM-dd, ISO 8601) from unstructured text.
  • Check file extension or path patterns before using them in a glob or find command.
  • Verify that a pattern correctly handles Unicode characters, accented letters, and multibyte characters when processing international text.

Before you rely on the result

  • Test both matching inputs and non-matching inputs — many regex bugs only show up when the pattern incorrectly matches something it should not.
  • Anchor patterns with ^ and $ when the entire input string must match (like form validation). Without anchors, a pattern can match a substring inside an otherwise invalid input.
  • Avoid overly broad .* sections when a more specific character class or non-greedy quantifier is appropriate, to prevent unintended over-matching.
  • Check that your regex handles empty strings, whitespace-only strings, and strings with special characters that appear in real user input.
  • Be careful with catastrophic backtracking: nested quantifiers like (a+)+ can cause exponential time complexity on adversarial inputs. Test with long non-matching strings.
  • JavaScript regex uses a slightly different syntax from Java (java.util.regex) and Python (re module) for features like lookahead, named groups, and Unicode. Verify your pattern in the target language after testing here.
  • Consider using verbose mode or comments in complex patterns to document what each section does, even if the tester does not support them directly.