Regex Tester
Live Matches & Capture Groups
Test JavaScript regular expressions with live match highlighting, capture groups, and g, i, m flag controls. Browser-only JS engine—not PCRE or Python.
This conversion runs only in your browser — nothing is uploaded.
- Matches—
- Flagsg
- Test string0
Test string
Output
What is this tool?
This regex tester compiles a JavaScript pattern in your browser, runs it against a test string, and shows live match highlighting, match count, and capture groups. Toggle the familiar g, i, and m flags without slash delimiters around the pattern.
Behavior matches the browser’s ECMAScript RegExp engine—not PCRE, Python, Java, .NET, or RE2. Use it to prototype validators, log extractors, and filename rules before you paste the pattern into application code.
Common use cases
- Debug why a form validator accepts or rejects a sample string
- Extract IDs or key=value pairs from a short log snippet with capture groups
- Compare greedy
.*vs lazy.*?(and multiline^/$) on the same text
How to use
- Enter a pattern without
/…/delimiters (e.g.\d+or(\w+)=(\S+)). - Toggle
g(all matches),i(ignore case), andm(^/$per line). - Paste a test string. Matches highlight live; capture groups list below when present.
- Use Sample for a multiline key=value example, Copy for the match/capture summary, Clear to reset.
Examples
| Pattern / flags | Test string | Result |
|---|---|---|
\d+ · g | Order 123 and 456 | Two matches: 123, 456. |
user-(\d+) | user-42 | Match user-42; capture 42. |
^id=.*$ · m | user=a / id=42 (two lines) | Matches the id=42 line only (m enables line ^/$). |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | Greedy takes one wide match; lazy takes shorter tag spans (edge vs greedy). |
[ (broken) | any | Invalid regex error. |
Practical pitfalls
- Engine mismatch: a pattern tuned in Python/
reor PCRE may fail or differ under JavaScript (lookbehind, possessive quantifiers, Unicode classes). - Greedy by default:
.*crosses delimiters you did not intend—prefer lazy quantifiers or tighter classes. - ReDoS / long input: nested quantifiers on large pastes can stall the tab. Keep the test string short while iterating; this page does not sandbox or time-limit the engine.
References
이 도구는 무엇인가요?
브라우저에서 JavaScript 정규식 패턴을 컴파일해 테스트 문자열에 적용하고, 실시간 매치 하이라이트, 매치 수, 캡처 그룹을 보여 줍니다. 패턴 양옆 / 없이 g·i·m 플래그를 토글합니다.
동작은 브라우저 ECMAScript RegExp 기준이며 PCRE·Python·Java·.NET·RE2와 다를 수 있습니다. 검증·로그 추출·파일명 규칙을 코드에 넣기 전에 확인하세요.
자주 쓰는 경우
- 폼 검증 패턴이 샘플을 통과·거부하는 이유 디버깅
- 짧은 로그에서 ID·key=value 캡처
- 같은 텍스트에서 탐욕
.*vs lazy.*?, 멀티라인^/$비교
사용 방법
/…/없이 패턴을 입력합니다 (예:\d+,(\w+)=(\S+)).g(전체)·i(대소문자 무시)·m(줄 단위^/$)를 켭니다.- 테스트 문자열을 붙이면 매치가 하이라이트되고, 캡처가 있으면 아래에 목록이 납니다.
- Sample은 멀티라인 key=value 예제, Copy는 매치/캡처 요약, Clear는 초기화입니다.
예시
| 패턴 / 플래그 | 테스트 문자열 | 결과 |
|---|---|---|
\d+ · g | Order 123 and 456 | 매치 2개: 123, 456 |
user-(\d+) | user-42 | 매치 user-42; 캡처 42 |
^id=.*$ · m | user=a / id=42 (두 줄) | id=42 줄만 매치 (m으로 줄 ^/$) |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | 탐욕은 넓게, lazy는 짧은 태그 구간 (탐욕 대비 엣지) |
[ (깨짐) | 아무 텍스트 | Invalid regex 오류 |
실무에서 흔한 실수
- 엔진 차이: Python/
re·PCRE용 패턴은 JS에서 실패하거나 다르게 동작할 수 있습니다. - 기본은 탐욕:
.*가 의도한 경계를 넘습니다. lazy나 더 좁은 문자 클래스를 쓰세요. - ReDoS·긴 입력: 중첩 수량자 + 대용량 붙여넣기는 탭을 멈출 수 있습니다. 디버깅 중에는 짧은 샘플만 사용하세요.
참고자료
このツールについて
ブラウザで JavaScript の正規表現をコンパイルし、テスト文字列に対するライブマッチ表示、件数、キャプチャグループを示します。パターンに / 区切りは不要で、g・i・m を切り替えます。
挙動はブラウザの ECMAScript RegExp 準拠で、PCRE・Python・Java・.NET・RE2 とは異なることがあります。バリデーションやログ抽出の前確認に使えます。
よくある用途
- フォーム検証パターンがサンプルを通す/落とす理由の確認
- 短いログから ID や key=value をキャプチャ
- 同じテキストで greedy
.*と lazy.*?、マルチライン^/$の比較
使い方
/…/なしでパターンを入力(例:\d+、(\w+)=(\S+))。g(全件)・i(大文字小文字無視)・m(行単位の^/$)を切り替え。- テスト文字列を貼るとマッチがハイライトされ、キャプチャがあれば下に一覧表示。
- Sample は複数行 key=value、Copy は要約、Clear でリセット。
例
| パターン / フラグ | テスト文字列 | 結果 |
|---|---|---|
\d+ · g | Order 123 and 456 | 2件: 123, 456 |
user-(\d+) | user-42 | マッチ user-42; キャプチャ 42 |
^id=.*$ · m | user=a / id=42(2行) | id=42 行のみ(m で行 ^/$) |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | greedy は広く、lazy は短いタグ幅(対比) |
[(不正) | 任意 | Invalid regex |
実務での落とし穴
- エンジン差: Python/
reや PCRE 向けパターンは JS で失敗・差異が出ることがあります。 - 既定は greedy:
.*が想定外の境界を越えます。lazy や狭いクラスを使ってください。 - ReDoS / 長文: 入れ子量化子と大きな貼り付けはタブを固めることがあります。短いサンプルで試してください。
参考資料
¿Qué es esta herramienta?
Este probador compila un patrón JavaScript en el navegador, lo aplica a un texto de prueba y muestra resaltado en vivo, recuento y grupos de captura. Activa g, i y m sin delimitadores /…/.
El comportamiento sigue el RegExp ECMAScript del navegador—no PCRE, Python, Java, .NET ni RE2. Úsalo para validadores, extractores de logs y reglas de nombre antes de llevar el patrón al código.
Casos de uso comunes
- Depurar por qué un validador acepta o rechaza una cadena
- Extraer IDs o pares key=value de un log corto con capturas
- Comparar greedy
.*vs lazy.*?y multilínea^/$en el mismo texto
Cómo usar
- Introduce el patrón sin
/…/(p. ej.\d+o(\w+)=(\S+)). - Activa
g(todas),i(ignorar mayúsculas) ym(^/$por línea). - Pega el texto de prueba. Las coincidencias se resaltan; las capturas aparecen debajo.
- Sample carga un ejemplo multilínea key=value; Copy resume coincidencias; Clear reinicia.
Ejemplos
| Patrón / flags | Texto | Resultado |
|---|---|---|
\d+ · g | Order 123 and 456 | Dos coincidencias: 123, 456. |
user-(\d+) | user-42 | Coincidencia user-42; captura 42. |
^id=.*$ · m | user=a / id=42 (dos líneas) | Solo la línea id=42 (m habilita ^/$ por línea). |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | Greedy toma un tramo ancho; lazy tramos más cortos. |
[ (roto) | cualquiera | Error de regex inválida. |
Errores prácticos
- Motor distinto: un patrón de Python/
reo PCRE puede fallar o diferir en JavaScript. - Greedy por defecto:
.*cruza delimitadores no deseados—usa lazy o clases más estrictas. - ReDoS / texto largo: cuantificadores anidados en pegados grandes pueden congelar la pestaña. Mantén muestras cortas al depurar.
Referencias
Qu'est-ce que cet outil ?
Ce testeur compile un motif JavaScript dans le navigateur, l’applique à une chaîne de test et affiche le surlignage en direct, le nombre de correspondances et les groupes de capture. Activez g, i et m sans délimiteurs /…/.
Le comportement suit le RegExp ECMAScript du navigateur—pas PCRE, Python, Java, .NET ni RE2. Utile pour validateurs, extracteurs de journaux et règles de noms avant d’intégrer le motif au code.
Cas d'usage courants
- Comprendre pourquoi un validateur accepte ou refuse un échantillon
- Extraire des IDs ou paires key=value d’un court journal avec des captures
- Comparer greedy
.*vs lazy.*?et multiligne^/$sur le même texte
Comment utiliser
- Saisissez le motif sans
/…/(ex.\d+ou(\w+)=(\S+)). - Activez
g(toutes),i(ignorer la casse) etm(^/$par ligne). - Collez la chaîne de test. Les correspondances sont surlignées ; les captures s’affichent en dessous.
- Sample charge un exemple multiligne key=value ; Copy résume ; Clear réinitialise.
Exemples
| Motif / flags | Chaîne | Résultat |
|---|---|---|
\d+ · g | Order 123 and 456 | Deux correspondances : 123, 456. |
user-(\d+) | user-42 | Correspondance user-42 ; capture 42. |
^id=.*$ · m | user=a / id=42 (deux lignes) | Seulement la ligne id=42 (m active ^/$ par ligne). |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | Greedy prend un large span ; lazy des spans plus courts. |
[ (cassé) | n’importe quoi | Erreur de regex invalide. |
Pièges courants
- Moteur différent : un motif Python/
reou PCRE peut échouer ou différer en JavaScript. - Greedy par défaut :
.*traverse des délimiteurs non voulus—préférez lazy ou des classes plus serrées. - ReDoS / longue entrée : quantificateurs imbriqués sur de gros collages peuvent figer l’onglet. Gardez des échantillons courts.
Références
这个工具是什么?
此工具在浏览器中编译 JavaScript 正则,对测试字符串显示实时匹配高亮、匹配数与捕获组。无需 /…/ 定界符,可切换 g、i、m。
行为遵循浏览器 ECMAScript RegExp,与 PCRE、Python、Java、.NET、RE2 可能不同。适合在写入业务代码前验证校验、日志提取与文件名规则。
常见用途
- 调试表单校验为何通过或拒绝某字符串
- 从短日志中用捕获组提取 ID 或 key=value
- 在同一文本上对比贪婪
.*与惰性.*?,以及多行^/$
如何使用
- 输入不含
/…/的模式(如\d+或(\w+)=(\S+))。 - 切换
g(全部匹配)、i(忽略大小写)、m(按行^/$)。 - 粘贴测试字符串;匹配会高亮,有捕获组时列在下方。
- Sample 载入多行 key=value 示例;Copy 复制匹配/捕获摘要;Clear 清空。
示例
| 模式 / 标志 | 测试字符串 | 结果 |
|---|---|---|
\d+ · g | Order 123 and 456 | 两个匹配:123、456 |
user-(\d+) | user-42 | 匹配 user-42;捕获 42 |
^id=.*$ · m | user=a / id=42(两行) | 仅匹配 id=42 行(m 启用行首尾) |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | 贪婪跨度更宽;惰性更短(对比边缘) |
[(非法) | 任意 | Invalid regex 错误 |
实践中的常见误区
- 引擎差异: 面向 Python/
re或 PCRE 的模式在 JS 中可能失败或表现不同。 - 默认贪婪:
.*会越过你不想跨的边界——改用惰性量词或更紧的字符类。 - ReDoS / 长输入: 嵌套量词加大段粘贴可能卡住标签页。调试时请用短样例。
参考资料
這個工具是什麼?
此工具在瀏覽器中編譯 JavaScript 正規表示式,對測試字串顯示即時比對醒目提示、相符數與擷取群組。無需 /…/ 定界符,可切換 g、i、m。
行為遵循瀏覽器 ECMAScript RegExp,與 PCRE、Python、Java、.NET、RE2 可能不同。適合在寫入業務程式碼前驗證校驗、日誌擷取與檔名規則。
常見用途
- 除錯表單校驗為何通過或拒絕某字串
- 從短日誌中用擷取群組提取 ID 或 key=value
- 在同一文字上對比貪婪
.*與惰性.*?,以及多行^/$
如何使用
- 輸入不含
/…/的模式(如\d+或(\w+)=(\S+))。 - 切換
g(全部相符)、i(忽略大小寫)、m(依行^/$)。 - 貼上測試字串;相符會醒目提示,有擷取群組時列在下方。
- Sample 載入多行 key=value 範例;Copy 複製相符/擷取摘要;Clear 清空。
範例
| 模式 / 旗標 | 測試字串 | 結果 |
|---|---|---|
\d+ · g | Order 123 and 456 | 兩個相符:123、456 |
user-(\d+) | user-42 | 相符 user-42;擷取 42 |
^id=.*$ · m | user=a / id=42(兩行) | 僅相符 id=42 行(m 啟用行首尾) |
<(.+)> vs <(.+?)> · g | <a>x</a><b>y</b> | 貪婪跨度較寬;惰性較短(對比邊緣) |
[(非法) | 任意 | Invalid regex 錯誤 |
實務上常見陷阱
- 引擎差異: 面向 Python/
re或 PCRE 的模式在 JS 中可能失敗或表現不同。 - 預設貪婪:
.*會越過你不想跨的邊界——改用惰性量詞或更緊的字元類。 - ReDoS / 長輸入: 巢狀量詞加大段貼上可能卡住分頁。除錯時請用短樣例。
參考資料
Last reviewed: 2026-07-27
Frequently asked questions
- Which regex engine is used?
- The browser’s JavaScript RegExp engine. Lookbehind, Unicode property escapes, and backtracking follow ECMAScript—not PCRE, Python, Java, .NET, or RE2. Patterns that work in those engines may fail or behave differently here.
- What do the g, i, and m flags do?
- g (global) finds every match; without it only the first match is shown. i ignores case. m makes ^ and $ match line starts/ends, not only the whole string.
- Why does my “greedy” pattern swallow too much?
- Quantifiers like .* and .+ are greedy by default and take the longest match. Use .*? or .+? for a lazy (shortest) match, or tighten the character class so it cannot cross the boundary you care about.
- Can a pathological pattern freeze the tab?
- Yes. Nested quantifiers on long input (classic ReDoS shapes) can make the JS engine backtrack heavily. Keep samples short while debugging; do not paste huge logs into catastrophic patterns.