Regex Tester
Test and debug regular expressions instantly online. Highlights matches, shows capture groups, and supports all JavaScript regex flags (g, i, m, s). Free regex tester — no signup required.
Pattern/g
Test String
Related Tools
Unix Timestamp
Convert Unix timestamps to UTC, local time, and ISO 8601 instantly. Auto-detects seconds vs milliseconds.
Base Converter
Convert numbers between decimal, hex, binary, and octal instantly. Free and runs in your browser.
Hash Generator
Generate SHA-1, SHA-256, SHA-384, and SHA-512 hashes instantly. Runs entirely in your browser using the Web Crypto API.
Regular expressions are a formal language for pattern matching in strings, derived from Kleene's theoretical work on regular languages and implemented in virtually every programming language. JavaScript's RegExp engine supports the ECMAScript specification with Unicode mode, named capture groups, lookbehind assertions, and the g, i, m, s, u, and v flags introduced across ES2015–ES2024.
Developers use regular expressions constantly: validating email addresses and phone numbers in form inputs, extracting data from log files, performing find-and-replace transformations in text pipelines, parsing structured strings like log entries or CSV-like formats, and writing URL routing rules. Regex errors cause subtle bugs and security issues (ReDoS vulnerabilities).
This tool tests regular expressions using JavaScript's built-in RegExp constructor and String.matchAll(). It supports all four commonly needed flags (g for global, i for case-insensitive, m for multiline, s for dotAll), highlights all matches inline in the input text, and displays capture groups (both numbered and named) for each match in a structured table.
Common Use Cases
Building log parsing patterns
Apache and NGINX access logs, application logs from Log4j or Winston, and structured syslog entries all follow predictable formats. Writing a regex to extract IP addresses, HTTP status codes, request paths, and timestamps from log lines — before deploying it in a Logstash filter, a Python re.findall() call, or an AWS CloudWatch Insights query — requires iterative testing against real log samples.
Validating form input patterns
HTML5 input pattern attributes, JavaScript form validators, and backend validation libraries (Joi, Zod, Pydantic) use regular expressions to validate phone numbers, postal codes, credit card numbers, and custom ID formats. Testing the regex against valid and invalid samples before embedding it in a schema definition prevents both false positives and false rejections.
Writing VS Code search and replace patterns
VS Code's find-and-replace and the sed, perl, and awk command-line tools all accept regular expressions with capture group back-references. Developers writing refactoring patterns — renaming function signatures, transforming import paths, converting date formats in bulk — test the match pattern and replacement expression before running it across thousands of source files.
Crafting named capture groups for parsers
Modern regex engines including JavaScript support named capture groups (?<name>...), which produce structured objects from unstructured text. When building a parser for a domain-specific format — a custom log format, a DSL, or a structured filename convention — testing named groups against real input confirms that each named field extracts the correct substring.
Supported Flags
- g (global) — find all matches in the string, not just the first
- i (case-insensitive) — match upper and lower case letters
- m (multiline) —
^and$match the start/end of each line - s (dotAll) — dot
.matches newline characters