JavaScript Regex Tester
Enter a raw JavaScript pattern and sample text, choose the flags, then test explicitly. Inspect the current matches and capture values without uploading your text.
Input
Pattern: up to 2,048 UTF-16 units; text: up to 100,000. Results and reports also have limits.
The tool processes your pattern and text in a browser worker without adding an upload, input history or content-bearing URL. Copy and download happen only when you choose them; the report contains your full pattern and text.
Test a pattern in three steps
- Enter the pattern without surrounding slashes or a trailing flags string, then enter your test text. Empty patterns and empty text are allowed.
- Choose the flags. All matches and Unicode mode start enabled; turn All matches off when you want only the first match.
- Select Test pattern. Inspect the matches, positions and captures, then optionally copy or download the complete current report, which includes your full input.
Read matches and captures accurately
A full match is the text accepted by the entire pattern. Parentheses can also capture values; a group that did not participate is different from one that matched an empty string.
Start positions count from zero and end positions are exclusive. Positions use JavaScript UTF-16 code units, so an emoji can occupy two positions even with Unicode mode enabled.
Multiline changes line anchors; Dot matches line breaks changes the dot. Unicode mode changes parsing and empty-match advancement, but does not make the usual word shorthand include every language's letters.
Values are shown in quoted JSON-string notation so empty, invisible and surrogate characters remain distinguishable. The exported report uses ASCII escapes and preserves the admitted pattern and text.
Examples worth checking
For pattern (\d+) and text Order 42, item 7, All matches returns 42 at [6,8) and 7 at [15,16), with each number also in capture 1. First match only returns 42.
An empty pattern on one emoji returns empty matches at positions 0 and 2 with All matches and Unicode mode. Without Unicode mode, it also returns one at position 1.
For pattern (a)?() on empty text, the full match is empty. Capture 1 is unmatched, while capture 2 participated and contains an empty string.
Scope and limits
This tool uses your browser's JavaScript regex engine with g, i, m, s and u flags. It does not offer PCRE, Python, replacement, capture positions or a guarantee of identical behavior across engines and versions.
Patterns are limited to 2,048 UTF-16 units and text to 100,000. Complete results allow at most 500 matches, 256 numbered and 256 named captures per returned match, and a 1 MiB report. Exceeding a limit produces no partial report.
A separate worker has a nominal two-second operation budget, including startup and reporting. Browser scheduling can delay cancellation, and a timeout does not prove that a pattern is invalid or unsafe.
This is a text-inspection aid, not a proof that a regex is safe, fast, secure or correct for every input. First match only reports the requested first result, not an exhaustive nonzero total.
Local handling
The tool processes your pattern and text in a browser worker without adding an upload, input history or content-bearing URL. Copy and download happen only when you choose them; the report contains your full pattern and text.
JavaScript regex questions
Sources and references
- tc39.esECMAScript 2026ECMAScript 2026 specifies JavaScript regular expressions and matching. Available syntax and behavior depend on your browser's engine and version.
- html.spec.whatwg.orgHTML StandardThe HTML Standard describes workers and their termination. Browser scheduling may delay the nominal two-second deadline; it is not a hard real-time guarantee.
Related tools
JSON to YAML
Convert JSON to YAML locally while preserving number text and quoted strings; copy or download the complete result.
Open tool — JSON to YAMLYAML to JSON
Convert one YAML document locally to JSON with exact number text and bounded aliases, then copy or download the complete result.
Open tool — YAML to JSONHTML to Markdown
Convert pasted or local HTML into Markdown, review conversion notes, and copy or download the result.
Open tool — HTML to MarkdownMarkdown to HTML
Convert a Markdown draft to an HTML fragment, inspect the source and inert preview, then copy or download it.
Open tool — Markdown to HTMLText Sorter
Sort lines alphabetically by a chosen language or by Unicode code point, keeping duplicates, blank rows and complete line contents.
Open tool — Text SorterRemove Duplicate Lines
Keep the first copy of each exact text line, preserving order, significant spaces and blank rows, then copy or download the result.
Open tool — Remove Duplicate LinesText Diff Checker
Compare two drafts locally, with exact whole-line changes, visible whitespace rules and clear final-newline handling.
Open tool — Text Diff CheckerCase Converter
Convert text to uppercase, lowercase, capitalized words or sentence case with explicit letter rules.
Open tool — Case ConverterHTML Entity Encoder/Decoder
Encode or decode literal HTML references with explicit context, Unicode options and LF output, without parsing or rendering markup.
Open tool — HTML Entity Encoder/DecoderMarkdown Table Generator
Edit a small literal-text table, set alignment and copy GFM Markdown or import tab-separated text.
Open tool — Markdown Table GeneratorQuery String Parser & Builder
Edit ordered URL parameters, retain repeated names and copy a normalized query or HTTP(S) URL.
Open tool — Query String Parser & BuilderURL Encoder & Decoder
Convert a UTF-8 URL component or form value with explicit space and plus rules, then copy or download the result.
Open tool — URL Encoder & DecoderBase64 Encoder & Decoder
Encode UTF-8 text as standard or URL-safe Base64, or decode either format with clear errors and complete text output.
Open tool — Base64 Encoder & DecoderXML Formatter
Check namespace-aware XML 1.0, format or compact locally, and copy or download UTF-8 output.
Open tool — XML FormatterJSON Formatter & Validator
Check JSON syntax, format or minify locally, and copy or download output while preserving original data tokens.
Open tool — JSON Formatter & ValidatorSMS Character Counter & Segment Calculator
See how your message is encoded, where its segments end and what it may cost. Your text stays in your browser.
Open tool — SMS Character Counter & Segment CalculatorSocial Media Character Counter
Check platform-specific limits and split posts without losing text.
Open tool — Social Media Character CounterCharacter Counter
Count characters, words, sentences and paragraphs. Check word density, reading time and UTF-8 size, all in your browser.
Open tool — Character CounterText Size Calculator
Compare text encodings and payload sizes in your browser.
Open tool — Text Size CalculatorPDF Text Cleaner
Fix line breaks and spacing in text copied from a PDF. Preserve your original and review ambiguous hyphens before copying the cleaned text.
Open tool — PDF Text CleanerFancy Text Converter
Convert supported fancy Unicode letters to normal text locally. Keep case, accents, emoji and your original text.
Open tool — Fancy Text ConverterGarbled Text Fixer
Fix garbled text and repair broken accents with a browser-based mojibake fixer. Review each possible UTF-8 reversal before applying it.
Open tool — Garbled Text FixerGmail Clipping Checker
Measure email HTML bytes in UTF-8, compare them with an advisory 102,000-byte Gmail reference, and inspect size contributors locally.
Open tool — Gmail Clipping Checker