정규식 참고 카드 및 테스터
실시간 패턴 테스트 및 일치 강조 표시가 있는 대화식 정규식 참조.
이 도구에 대해
앵커, 문자 클래스, 수량자, 그룹 및 특수 문자를 다루는 포괄적이고 분류된 정규식 참조를 탐색하세요 — 각 항목에는 기호, 이름, 설명 및 실제 예제가 포함됩니다. 상단의 빠른 테스터를 사용하여 텍스트와 패턴을 입력하고 실시간으로 일치 항목이 강조 표시되는 것을 확인하세요. 원클릭 복사로 모든 패턴을 즉시 클립보드에 저장하세요.
사용 방법
- 1 상단의 텍스트 영역에 테스트 문자열을 입력하거나 붙여넣으세요.
- 2 정규식 패턴을 입력하고 필요에 따라 플래그(g, i, m, s)를 선택하세요.
- 3 일치 항목이 실시간으로 강조 표시됩니다; 일치 수가 입력 아래에 표시됩니다.
- 4 아래의 참조 표를 탐색하고 항목에서 '복사'를 클릭하여 해당 패턴을 복사하세요.
What a regular expression really is
A regular expression (regex) is a compact pattern that describes a set of strings. Instead of searching for one literal word, you describe its shape — "three digits," "a word at the start of a line," "anything between angle brackets" — and the engine finds every piece of text that fits. This page is two things at once: a categorised cheat sheet of the building blocks, and a live tester where you type a pattern and watch it highlight matches in your own text in real time. Learning regex by reading definitions is slow; learning it by seeing a pattern light up exactly what you expected is fast.
The five families of building blocks
Every regex is assembled from a small vocabulary. The cheat sheet groups them into five categories, each with a runnable example you can copy:
- Anchors match positions, not characters:
^(start),$(end), and\b(word boundary).\bcat\bmatches "cat" in "the cat sat" but not the "cat" inside "concatenate." - Character classes match one character from a set:
\d(digit),\w(word character),\s(whitespace),[aeiou](any listed character),[^...](anything not listed), and.(any character except newline). - Quantifiers say how many:
*(zero or more),+(one or more),?(optional), and{2,4}(between two and four). Their lazy versions, like*?, match as few characters as possible. - Groups and lookarounds:
(...)captures,(?:...)groups without capturing, and lookahead/lookbehind such as(?<=\$)\d+match a position based on what surrounds it without consuming those characters. - Special characters: alternation
|(or), plus escapes for newline\n, tab\t, and carriage return\r.
Greedy versus lazy: the classic trap
This is the single most common source of regex confusion. By default quantifiers are greedy — they grab as much as they can. Run <.*> against <b>bold</b> in the tester and it matches the entire string, from the first < to the last >, because .* swallowed everything in between. Add a single ? to make it lazy — <.*?> — and it now matches just <b>, then </b> separately, because the engine stops at the first > it can. Seeing both behaviours highlighted side by side makes the difference click instantly.
Flags change the rules
The tester exposes the four flags you toggle most:
| Flag | Effect |
|---|---|
g | Global — find all matches, not just the first (on by default here so the tester can highlight every hit). |
i | Case-insensitive — cat also matches "Cat" and "CAT". |
m | Multiline — ^ and $ match the start and end of each line, not just the whole string. |
s | Dotall — . also matches newline characters. |
A worked example: validating a price
Suppose you want every dollar amount in a sentence. Paste The shirt is $25 and the hat is $9 into the test string and type the pattern \$\d+. The \$ escapes the literal dollar sign (an unescaped $ would mean "end of string"), and \d+ grabs one or more digits after it. The tester highlights $25 and $9 and reports "2 matches." Want only the number, not the sign? Use a lookbehind: (?<=\$)\d+ matches the digits while leaving the $ out of the highlight.
Common mistakes the tester helps you catch
- Forgetting to escape special characters. A literal dot, dollar, question mark, or parenthesis must be written
\.,\$,\?,\(. An unescaped one means something else entirely. - Greedy matches that overreach. If your pattern grabs far more than intended, reach for the lazy version first.
- Assuming
.matches everything. By default it skips newlines — add thesflag if your text spans multiple lines. - Invalid syntax. If your pattern won't compile, the tester shows the exact error message in red instead of silently failing, so you can fix the typo on the spot.
Privacy
The tester uses your browser's own built-in regex engine (the same one JavaScript uses), so every pattern and every test string is evaluated locally. Nothing you type — neither your patterns nor the text you test them against — is sent to or stored on any server.