Skip to content
cosmodev ~/tools/regex-tester

정규식 테스터

Validators & Testers

모든 플래그(g/i/m/s/u/y)로 정규 표현식을 임의의 텍스트에 대해 테스트하세요. 모든 매치와 그 인덱스, 캡처 그룹, 구성된 패턴을 확인할 수 있습니다. 100% 브라우저에서 동작합니다.

예시

일치 항목이 강조되는지 보려면 테스트 문자열을 입력하세요.

패턴
/gi
//gi
플래그
테스트 문자열
0 일치
일치 항목
일치 항목이 없어요.
Send to AI
Critique this regex for catastrophic backtracking and RE2 compatibility, then propose a stricter version with tradeoffs:

`//gi`

Matches found:
(none)

(문서는 영어)

What it does

Tests a JavaScript regular expression against any text, live as you type. Type a pattern, toggle any of the six flags (g global, i ignore case, m multiline, s dotAll, u unicode, y sticky), and the tool lists every match with its index and capture groups, highlights all hits in the test string, and shows the constructed /pattern/flags literal ready to copy.

It uses your engine’s native RegExp - the same semantics your code will get - and reports invalid patterns with the engine’s own error message (e.g. missing terminating ] for character class) instead of a generic failure. Matching is capped at 2000 matches, and zero-width matches are detected and displayed as thin markers rather than hanging the loop. 100% in-browser.

How to use it

  1. Click a preset in the toolbar - Email, URL, Date, Hex color, or Capture - to load a ready-made pattern, flag set, and sample text. Each preset sets all six flags explicitly, so switching presets never leaves a stale flag on.
  2. Type your pattern in the Pattern field (shown between / delimiters, with the active flags appended live). Click Copy in the section header to copy the full /pattern/flags literal.
  3. Toggle any of the six Flags; each toggle shows its name and a one-line hint (e.g. s dotAll - “. also matches newlines”). Defaults are g + i.
  4. Type or paste text into Test string - the row label shows the live match count.
  5. Watch the Match preview: every hit is outlined; zero-length matches appear as a thin bar so you can see where they land.
  6. Read Matches: one card per match with #n @ index, the matched text, and each capture group ([1], [2], …) with (undefined) for groups that did not participate.
  7. Click Clear (toolbar) to reset pattern, flags, and test string in one tap.
  8. Below the output, the prompt bar copies a pre-filled AI prompt built from your live values - Critique & improve (checks the pattern for catastrophic backtracking) or Generate Python tests (writes re unit tests from the current matches).

Examples

Verified by running the tool’s exact matching loop (same RegExp construction and exec walk as the island) on the built-in presets:

Email preset /[\w.+-]+@[\w-]+\.[\w.]+/gi on Contact ada@example.com or bob@test.co.uk today.

1. "ada@example.com" @ 8
2. "bob@test.co.uk" @ 27

Capture preset /(\w+)@(\w+)/g on ada@example bob@test - groups listed per match:

1. "ada@example" @ 0 → [ada, example]
2. "bob@test" @ 12 → [bob, test]

Hex color preset /#(?:[0-9a-f]{3}|[0-9a-f]{6})\b/gi on Brand #3b82f6, accent #38BDF8, short #fff.

1. "#3b82f6" @ 6
2. "#38BDF8" @ 22
3. "#fff" @ 37

No g flag - only the first match is reported. Pattern /\d{4}-\d{2}-\d{2}/ on Shipped 2026-08-15, due 2026-09-01. → 1. "2026-08-15" @ 8 (with g, both dates match: @ 8 and @ 24).

Zero-width pattern /\b/g on ab → two empty matches at @ 0 and @ 2, rendered as thin markers in the preview.

Good to know

  • Private: matching runs entirely in your browser; nothing you paste is uploaded.
  • The dialect is ECMAScript (RegExp). Lookbehind, named groups, and u-mode properties work if your browser supports them - the tool imposes nothing on top.
  • The y (sticky) flag makes matches start at lastIndex, so a sticky pattern often yields zero matches until the text aligns - that is the flag working, not a bug.
  • Empty test string shows a hint instead of a preview; an invalid pattern keeps the text visible with the engine’s error below it.
  • Related tools: Regex Explainer, Find & Replace, Text Diff Viewer
소스 코드14개 언어

100% 클라이언트 측 · 데이터는 브라우저 밖으로 나가지 않습니다. 도움이 되었나요? 팀원에게 공유해 보세요.