Regex Tester

Test regular expressions with real-time matching and highlighting. Supports JavaScript regex flags (g, i, m, s). See match groups, captures, and indices. Free online regex tester.

/ /

Enter a regex pattern and test string above — results update live

About Regular Expressions

Regular expressions (regex or regexp) are sequences of characters that define search patterns. They are one of the most powerful tools in a developer's toolkit, used for matching, extracting, and manipulating text across virtually every programming language — JavaScript, Python, Java, Go, PHP, Ruby, and more. Whether you're validating user input, parsing log files, extracting data from HTML, or performing complex find-and-replace operations, regex provides a concise and flexible syntax to describe exactly what you're looking for.

A regular expression engine works by compiling your pattern into a state machine that processes the input string character by character. When the engine finds a sequence of characters that satisfies the pattern, it reports a match. Modern regex engines support features like lookaheads, lookbehinds, non-greedy quantifiers, and named capture groups — making it possible to express remarkably complex matching logic in a single line.

This online regex tester uses JavaScript's built-in RegExp engine, which means your patterns will behave exactly as they would in any browser or Node.js environment. The tool highlights matches in real time as you type, shows capture groups and their indices, and supports all JavaScript regex flags. It's ideal for prototyping patterns before embedding them in your code, debugging why a pattern isn't matching what you expect, or learning regex syntax interactively.

Developers frequently use regex alongside other tools in their workflow. For example, you might use a regex to extract Unix timestamps from log files, validate that a string is a properly formatted UUID, or parse the payload of a JSON Web Token. Understanding regex is a foundational skill that pays dividends across every area of software development.

JavaScript Regex Flags

  • g — Global: find all matches, not just the first
  • i — Case-insensitive matching
  • m — Multiline: ^ and $ match line boundaries
  • s — Dotall: . matches newline characters
  • u — Unicode: treat pattern as Unicode code points
  • y — Sticky: match from lastIndex position only

Practical Regex Examples

1. Validate an email address:

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

This pattern checks for a standard email format: one or more valid characters before the @, a domain name, and a top-level domain of at least two characters. While not RFC 5322 compliant, it covers the vast majority of real-world email addresses.

2. Extract IPv4 addresses from text:

\b(\d{1,3}\.){3}\d{1,3}\b

Matches patterns like 192.168.1.1 or 10.0.0.255. The \b word boundaries prevent matching partial numbers embedded in longer strings. Useful when parsing network logs or configuration files — pairs well with our Subnet Calculator for network planning.

3. Match a UUID v4 format:

[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}

This pattern specifically matches UUID version 4 strings, checking that the version nibble is 4 and the variant bits are correct. Use the i flag for case-insensitive matching.

4. Parse a date in YYYY-MM-DD format:

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

Captures year, month, and day as separate groups. The month is restricted to 01-12 and the day to 01-31. Each group can be accessed individually in your code for further processing.

5. Find all URLs in a block of text:

https?://[^\s<>"{}|\\^`\[\]]+

Matches HTTP and HTTPS URLs by starting at the protocol and consuming everything that isn't whitespace or a character that typically terminates a URL in context. Useful for link extraction from documents or chat logs.

Character Classes Quick Reference

  • \d — Digit [0-9]
  • \D — Non-digit
  • \w — Word character [a-zA-Z0-9_]
  • \W — Non-word character
  • \s — Whitespace (space, tab, newline)
  • \S — Non-whitespace
  • . — Any character (except newline by default)
  • \b — Word boundary (zero-width)

Quantifiers

  • * — Zero or more (greedy)
  • + — One or more (greedy)
  • ? — Zero or one (optional)
  • {n} — Exactly n times
  • {n,m} — Between n and m times
  • *?, +? — Non-greedy (lazy) versions

Frequently Asked Questions

What is the difference between greedy and lazy regex matching?

Greedy quantifiers (*, +, {n,m}) match as many characters as possible while still allowing the overall pattern to succeed. Lazy quantifiers (*?, +?, {n,m}?) match as few characters as possible. For example, given the string "<b>hello</b>", the greedy pattern <.+> matches the entire string, while the lazy pattern <.+?> matches only "<b>". Use lazy matching when you want the shortest possible match.

How do I match a literal dot or special character in regex?

Special characters like . * + ? ^ $ { } [ ] ( ) | \ have special meaning in regex. To match them literally, escape them with a backslash. For example, use \. to match a period, \$ to match a dollar sign, or \[ to match a literal bracket. Inside a character class [...], most special characters lose their meaning except for ] \ ^ and -.

What are capture groups and how do I use them?

Capture groups are created by wrapping part of your pattern in parentheses (). They serve two purposes: grouping (to apply quantifiers to a sub-expression) and capturing (to extract the matched text). In JavaScript, captured groups are accessible via match[1], match[2], etc. Named groups use the syntax (?<name>...) and can be accessed via match.groups.name. Non-capturing groups (?:...) group without capturing, which is slightly more efficient when you don't need the matched text.

Why does my regex work in one language but not another?

Regex flavors differ between languages. JavaScript doesn't support lookbehinds with variable length (though modern engines are adding support), POSIX regex lacks lookaheads entirely, and Python's re module has different Unicode handling than JavaScript. Features like atomic groups, possessive quantifiers, and conditional patterns are available in some engines (PCRE, .NET) but not others. Always test your regex in the target language's engine. This tool uses JavaScript's RegExp, which matches browser and Node.js behavior.

Is this regex tester safe to use with sensitive data?

Yes. This regex tester runs entirely in your browser using JavaScript. No data is transmitted to any server — your patterns and test strings never leave your machine. You can verify this by checking the network tab in your browser's developer tools while using the tool.

Related Tools

Explore More Free Tools

🔧

Cron Expression Generator

Generate and validate cron expressions with a visual builder. See next execution times, human-readable descriptions, and common presets. Free online crontab generator for developers.

🔧

JWT Decoder

Decode and inspect JWT tokens instantly. View header, payload, and signature. Check expiration, issuer, and claims. Free online JWT decoder — no data sent to any server.

🔧

Unix Timestamp Converter

Convert Unix timestamps to human-readable dates and vice versa. Supports seconds and milliseconds. Shows current epoch time live. Free online tool for developers.

🔧

UUID Generator

Generate random UUIDs (v4), time-based UUIDs (v7), and ULIDs instantly. Bulk generate up to 100 at once. Free online UUID generator for developers — no signup required.

🔧

Base64 Encoder & Decoder

Encode text to Base64 or decode Base64 back to plain text instantly. Free online Base64 converter with file support and batch processing. No registration required.

🧮

CIDR Calculator & Network Analyzer

Calculate CIDR blocks, subnets, and network information from IP addresses and subnet masks with comprehensive analysis.

🎨

Color Palette Generator

Generate beautiful color palettes instantly. Create complementary, analogous, triadic, and monochromatic color schemes for web design, branding, and creative projects.

📊

IP Address Block Tool

Calculate network details from an IP address and subnet mask (CIDR notation).

📝

JSON Formatter & Validator

Format, validate, and beautify JSON data instantly with our free online JSON formatter. Supports minification, syntax highlighting, and error detection. No registration required.

🔧

JSON to YAML Converter

Convert JSON to YAML and YAML to JSON instantly with our free online converter. Supports validation, formatting, and syntax highlighting. No registration required.

🔑

Password Generator

Generate strong, secure passwords instantly with our free password generator. Customize length, character types, and complexity. No registration required, privacy-focused.

📊

Percentage Calculator

Calculate percentages, percentage increases/decreases, and compare values instantly. Free online percentage calculator with multiple calculation types and detailed results.

🔧

SEO Meta Tag Generator

Generate SEO-optimized meta tags instantly. Create title tags, meta descriptions, Open Graph tags, and Twitter Cards for better search engine visibility.

🔧

Tools Sitemap

Complete list of all free developer tools available on Ataiva. Find password generators, JSON formatters, converters, and more utilities for developers.

📏

Unit Converter

Convert between various units such as length, weight, temperature, and more.

🎨

Visual Subnet Calculator

Interactive visual subnet calculator with graphical representation of network segments and subnetting.

📄

Word Counter & Text Analyzer

Count words, characters, sentences, and paragraphs instantly. Analyze readability, text complexity, and writing style with our comprehensive text analyzer tool.