Skip to content
Regex toolkit

Regex tester with highlight and pattern library

Tester for JavaScript regex: paste a pattern (with gimsuy flags) and a test string, get match highlight, capture groups, match count. Categorized pattern library with ready-made regexes for: email, URL, IPv4/IPv6, MAC address, phone, ISO date, slug, hex color, plus Italian-specific (CF, P.IVA, IBAN). Fully.

Mode

How to use the regex tester

  1. 1

    Enter pattern and flags

    Pattern: without delimiters (no /.../), just the body. Flags: g (global, all matches), i (case-insensitive), m (multiline, ^$ match line start/end), s (dotAll. matches newline too), u (unicode), y (sticky).

  2. 2

    Paste the test string

    Free text, multi-line OK. The tester uses the browser's native RegExp engine (V8 / SpiderMonkey / JavaScriptCore), so syntax and perf match standard JS.

  3. 3

    Read the results

    Output: original string with matches highlighted in yellow, statistics (total matches, capture groups), match list with index. For capture groups: each match also shows captured groups with their index.

  4. 4

    Pattern library

    'Pattern library' button opens a categorized list of ready patterns: RFC-friendly email, HTTP/HTTPS URL, IPv4/IPv6, MAC address, Italian phone (landline and mobile), Italian fiscal code, VAT number, IBAN, ISO 8601 date, URL-safe slug. Click to load them in the pattern field.

JavaScript regex: why a dedicated tester

Differences across regex dialects. JavaScript regexes are ECMAScript-compliant but differ from PCRE (PHP, Perl), POSIX (grep, sed).NET, Python re. Example: variable-length lookbehinds are JS-supported since 2018 (ECMAScript 2018), missing in old browsers. Atomic groups (?>...) missing in JS (present in PCRE/Perl). Recursive patterns missing in JS. For reliable regex testing on complex patterns, use a tester from the same family as the destination runtime.

What this tool offers. Tester with browser-native RegExp, so it represents exactly what happens in production JS code. Match highlight in yellow for visualization. Numbered and named capture groups (syntax (?<name>...)). Match index. Pattern library of 12+ common regexes (Italian-specific included) ready to use.

Performance caveat. The tool does not detect catastrophic backtracking. Patterns like (a+)+ on long input freeze the browser tab. If the tester appears frozen: close the tab. For backtracking audit: redos-checker or dedicated tools. In production, use RE2 (linear-time, no backtracking) for regexes on untrusted input.

Included pattern library

CategoryPatternExample
Email^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$[email protected]
HTTP/HTTPS URL^https?://[^\s]+$https://www.example.com
IPv4^(?:\d{1,3}\.){3}\d{1,3}$192.168.1.1
MAC address^([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$aa:bb:cc:dd:ee:ff
Italian landline phone^(?:\+39)?0\d{1,4}\s?\d{4,8}$+39 06 1234567
Italian mobile phone^(?:\+39)?3\d{2}\s?\d{6,7}$+39 333 1234567
Italian fiscal code^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$RSSMRA80A01H501U
Italian VAT^\d{11}$12345678901
Italian IBAN^IT\d{2}[A-Z]\d{10}[A-Z0-9]{12}$IT60X0542811101000000123456
ISO 8601 date^\d{4}-\d{2}-\d{2}$2026-04-25
URL-safe slug^[a-z0-9]+(?:-[a-z0-9]+)*$my-tool-name
Hex color^#(?:[0-9a-fA-F]{3}){1,2}$#abc, #aabbcc

Glossary

Technical terms used on this page, briefly explained.

Regex #
Regular expression: formal pattern for string matching. Invented in the 60s (Stephen Kleene). Modern implementations: PCRE (Perl Compatible), ECMAScript (JavaScript), POSIX (grep/sed), RE2 (Google, linear-time).
Capture group #
Sub-expression in parentheses (...) that captures a substring. Numbered from 1 (group 0 = full match). Named group: (?<name>...). Non-capturing: (?:...).
Lookahead / Lookbehind #
Position assertions. (?=...) positive lookahead (match followed by). (?!...) negative lookahead. (?<=...) lookbehind. Variable-length supported in JS since 2018.
Backtracking #
Regex engine behavior when a partial match fails: it goes back and tries alternatives. Patterns like (a+)+ on input aaaaab have exponential complexity (catastrophic backtracking).
RE2 #
Google's regex engine with linear-time complexity. No backtracking, no lookbehind, no backreferences. Safe for regexes on untrusted input (no DoS via catastrophic backtracking). Used by Google, Cloudflare, GitHub Code Search.
Sticky flag (y) #
JS flag that restarts matching from the exact lastIndex position (no advancing). Useful for tokenizing parsers. Different from g which can skip non-matchable characters.

Frequently asked regex questions

How do I use a regex with flags in production JS?
Two syntaxes: literal /pattern/flags or constructor new RegExp('pattern', 'flags'). Literal is compiled at parse-time (no runtime overhead). Constructor is useful for dynamic patterns (e.g. user input). Caveat: in the constructor, escape sequences must be doubled ('\\d' for \d).
My regex is slow on long input: what to do?
Possible catastrophic backtracking. Typical offenders: (a+)+, (.*)*, alternations with common prefix. Three strategies: (1) refactor to a linear pattern (e.g. a+ instead of (a+)+); (2) atomic groups or possessive quantifiers (NOT available in JS, only PCRE); (3) use RE2 server-side for untrusted input (Node.js: re2 npm package; Go: regexp standard library).
Differences between JS regex vs PHP/Python?
JS ECMAScript: no atomic groups, no recursive, no possessive quantifiers, no backreferences in lookbehind. PHP PCRE / Python re: all supported. Example: pattern (?P<name>...) Python does NOT work in JS (different Python syntax). JS uses (?<name>...) ES2018+.
Does a 100% RFC-compliant email regex exist?
Technically: a RFC 5322 compliant regex is ~6,000 chars. In practice: nobody uses it. Pragmatic pattern (in library): ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ covers 99.99% of real cases. For rigorous validation: send confirmation email + click link.
Italian CF pattern: what does it actually check?
Only format (16 alphanumeric chars in the expected pattern). NOT the CIN (control character). For full validation including CIN: use the Italian ID validator on this site (italian-only, no EN equivalent). A regex cannot compute the CIN modulo-26 sum.
How to test regex with multiline input?
Flag m enables ^ and $ to match at start/end of each line (not just full string). Without m, ^ matches only the very start of input. Example: ^abc with m matches 'abc' at every line start.
Can I use unicode property classes (\p{...})?
Yes, with the u (Unicode) flag enabled. Syntax: \p{Letter} matches any Unicode letter (including accents, Cyrillic, etc). \P{Letter} NON-letter. Supported in all modern browsers (2020+).

Who builds these tools?

Maurizio Fonte, senior IT consultant with 20+ years in PHP, Laravel, unmanaged Linux infrastructure, applied cybersecurity and AI/LLM integration. Production backends, legacy code modernization, security audits, custom AI agents and MCP servers: the work behind every tool published here.

About Maurizio Fonte