使用繁體中文瀏覽?切換到繁體中文
使用简体中文浏览?切换到简体中文
日本語で表示しますか?日本語に切り替える
한국어로 보시겠어요?한국어로 전환
ดูหน้านี้เป็นภาษาไทยไหม?เปลี่ยนเป็นภาษาไทย
Lihat halaman ini dalam bahasa Indonesia?Beralih ke bahasa Indonesia
Xem trang này bằng tiếng Việt?Chuyển sang tiếng Việt
यह पेज हिन्दी में देखें?हिन्दी में बदलें
Voir cette page en français ?Passer au français
Diese Seite auf Deutsch ansehen?Zu Deutsch wechseln
¿Ver esta página en español?Cambiar a español
Visualizzare questa pagina in italiano?Passa all'italiano
Deze pagina in het Nederlands bekijken?Overschakelen naar Nederlands
Wyświetlić tę stronę po polsku?Przełącz na polski
Ver esta página em português?Mudar para português
Открыть страницу на русском?Переключить на русский
Bu sayfayı Türkçe görüntülemek ister misiniz?Türkçeye geç
عرض هذه الصفحة بالعربية؟التبديل إلى العربية
Skip to content

Regex Tester

Test JavaScript regular expressions locally with g/i/m/s/u/y flags, match counts, line-column ranges, capture groups, named groups, and native replace preview.

1A

Test Text

Regex Tester

Quick Start

1
Enter a regex pattern, choose flags (g/i/m/s/u/y), and paste test text.
2
Review matches, line ranges, capture groups, and named groups.
3
Enter a replacement template ($1, $2, $<name>) to preview String.replace output.
4
Copy the pattern or replacement result; Clear empties the workbench.

Common Scenarios

Data extraction

use (\\d{4}-\\d{2}-\\d{2}) to extract dates, and ([\\w.]+@[\\w.]+) to extract email addresses

Format validation

write a regex, paste multiple samples, and quickly verify whether the pattern precisely matches the target format

Batch replacement

use capture groups to restructure content. For example, convert "First Last" to "Last, First" with pattern (\\S+)\\s+(\\S+) and replacement $2, $1

Named groups

use (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) to extract dates, then use $<year>/$<month>/$<day> to rebuild them

Regex learning

try different patterns and observe matching behavior to understand quantifiers, anchors, and character classes visually

Multi-line handling

enable the m flag so ^ and $ match by line, useful for logs, code, and configuration files

Usage Advice

Global search (g) is enabled by default; turn it off only when you need the first match
In this tool, enter \\d, \\w, and \\s directly; no double escaping is needed like in code strings
m makes ^ and $ match by line, while s lets . match newline characters; they solve different problems and can be combined when needed
Prefer specific patterns over broad .* patterns to avoid unexpected matches.
Always verify replacement output before applying it elsewhere.
The tool includes performance-risk detection and warns about patterns that may cause catastrophic backtracking, such as nested quantifiers

Limitations & Compatibility

This tool uses your browser's JavaScript RegExp engine. It does not switch to PCRE, Python, Java, Go, recursive patterns, conditional branches, or atomic groups.
Lookbehind assertions (?<=...) require Chrome 62+ / Firefox 78+ / Safari 16.4+; JavaScript usually requires fixed length, so avoid variable quantifiers like * or + inside the assertion
Large text with complex patterns can trigger catastrophic backtracking. CrateX.app uses a worker, risk warning, safety mode, and timeout protection, but it is not a ReDoS proof.

Privacy & Security

Processing runs in your browser. The regex pattern, test text, replacement template, flags, line-number, and wrapping choices may stay in the current browser session or browser storage. If you save a workspace or enable WebDAV sync, those values may be saved according to your sync settings. Match details and replacement preview are derived from the current inputs and are not stored as separate results. On shared devices, clear the fields and site data when needed.

FAQ

6

Continue with these related tools for the next step.

Community

© CrateX.app · All Rights Reserved