텍스트
Regex Tester / Find & Replace
실제 텍스트로 정규식 테스트: 하이라이트된 일치 항목과 분석된 캡처 그룹, 또는 찾은 일치 항목을 새 텍스트로 바꾸기.
A regular expression (regex) is a compact language for describing patterns in text — for searching, validating a format, or replacing matches. This tool highlights matches in real text as you type the pattern, breaks out capture groups, and supports a find-and-replace mode.
How to use it
- Search: enter a pattern and some test text — every match is highlighted and capture groups are broken out separately.
- Replace: switch to Replace mode, provide a replacement template (referencing groups with $1, $2), and see the result instantly.
- Flags (g, i, m, s) toggle independently and immediately affect how many matches are found and how.
Common uses
- Building and debugging a regex before pasting it into code — you see the result without running the program.
- Bulk find-and-replace against a pattern (e.g. reformatting phone numbers or dates).
- Validating an input format (email, card number, slug) against real examples.
Things to keep in mind
Greedy quantifiers (*, +) grab as many characters as possible — add ? for the minimal match instead (e.g. .*? instead of .*).
Syntax varies slightly between languages — an expression that works here (a JavaScript engine) may need adjusting for PCRE, .NET, or Python.
자주 묻는 질문
어떤 정규식 엔진을 사용하나요?
브라우저의 자바스크립트 정규식 엔진을 사용합니다. PCRE 전용 문법(예: 후방탐색 조건부, 재귀 패턴 등 일부 고급 기능)은 지원되지 않을 수 있으며, g·i·m·s·u 같은 플래그와 이름 있는 캡처 그룹은 정상적으로 동작합니다.
탐욕적(greedy) 수량자와 게으른(lazy) 수량자의 차이는 무엇인가요?
*, +처럼 기본 수량자는 가능한 한 많이 일치시키는 탐욕적 방식이고, *?, +?처럼 물음표를 붙이면 가능한 한 적게 일치시키는 게으른 방식으로 동작합니다.
테스트 모드와 바꾸기 모드는 어떻게 다른가요?
테스트 모드는 패턴과 일치하는 부분을 하이라이트하고 캡처 그룹을 분석해 보여주며, 바꾸기 모드는 일치한 부분을 $1, $2 같은 그룹 참조를 포함한 문자열로 치환한 결과를 보여줍니다. 입력한 정규식과 텍스트는 브라우저 안에서만 처리됩니다.
파괴적 백트래킹이란 무엇인가요?
(a+)+ 같은 중첩된 수량자는 특정 입력 문자열에서 엔진이 지수적으로 많은 조합을 시도하게 만들 수 있습니다 — 겉보기에 단순한 표현식에서 페이지나 스크립트가 "멈춰버립니다". 이는 실제로 존재하는 취약점 종류(ReDoS)이므로, 복잡한 중첩 수량자는 길고 거의 일치하는 문자열로도 반드시 테스트해야 합니다.
왜 제 정규식이 한 프로그래밍 언어에서는 작동하는데 다른 언어에서는 작동하지 않나요?
정규식 문법은 완전히 표준화되어 있지 않습니다. PCRE(PHP를 비롯한 많은 언어), .NET, Python re, JavaScript는 특정 구문(예: 후방탐색이나 이름 있는 그룹) 지원에서 미묘한 차이가 있어, 한 엔진용으로 작성된 표현식이 다른 엔진에서 그대로 동작하지 않을 수 있습니다.