One of the listed characters · any other character
[가-힣]
One Hangul syllable
^ $
Start · end (per line with m)
\b
Word boundary
* + ?
0 or more · 1 or more · optional
{3} {2,5}
Exactly 3 · 2 to 5 times
*? +?
As few as possible (lazy)
(…) (?:…)
Group · non-capturing group
(?<name>…)
Named group
a|b
a or b
(?=…) (?!…)
Followed by … · not followed by …
(?<=…) (?<!…)
Preceded by … · not preceded by …
$1 $<name>
Insert a group in the replacement
Related searches
Regex Tester
regex tester online
regex tester tool
regex tester online free
regex tester 101
What is Regex Tester?
Lets you build a regular expression while instantly checking whether it matches the parts you want.
How to use
1
Enter a regular expression.
2
Paste the text to test.
3
Check that the matching parts are highlighted.
Tips
Results change a lot depending on flags such as g (global) and i (ignore case).
If it matches too broadly, use a specific character range instead of .*.
Frequently asked questions
QWhat does each regex flag mean?
g finds all matches and i ignores case. m applies ^ and $ to each line, and s makes . match line breaks too. u enables Unicode handling, and y is sticky mode, which matches only from the exact current position.
QCan it also replace matches with other text?
Turn on replace and enter a replacement string to see the result right away. You can use group numbers like $1, named groups as $<name>, and the whole match as $&. Copy the result with the copy button.
QIt says the pattern stopped because it did not finish within one second.
Repetition inside repetition, as in (a+)+, can make the amount of computation explode so that it does not finish in one second. The tool then stops and shows a notice so the page does not freeze. Reduce nested repetition or narrow the range specifically, for example [a-z].
Learn more
1Basic regular expression syntax
A dot (.) is any single character, \d is a digit, \w is a letter, digit or underscore, and \s is whitespace. * means 0 or more times, + means 1 or more, ? means 0 or 1, and {3,4} means 3 to 4 times. Square brackets [016789] mean one of the characters inside, parentheses make a group, and | means or. ^ and $ mean the start and the end.
For example, /01[016789]-\d{3,4}-\d{4}/ matches a mobile number such as '010-1234-5678'. In the text 연락처 010-1234-5678 입니다, only the 010-1234-5678 part is matched.
2Groups and replacing
The part wrapped in parentheses can be taken out separately in the result. Naming groups, as in (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}), makes it clear which value is which. If you enter $<d>/$<m>/$<y> in the replace field, 2026-10-20 becomes 20/10/2026.
This tool marks the matched parts in color and shows the value captured by each group and the replacement result. Common patterns and a syntax summary table are below.
3Things to watch
This tool uses the browser's JavaScript regular expressions. Some syntax differs from other languages such as Python, Java and PCRE (for example, the range of lookbehind support and flag names), so moving a pattern over as is may behave differently. When you move it, test it again in that language.
.* is greedy and grabs as much as possible, so add a ? as in .*? to make it stop where needed. Also, patterns with nested repetition such as (a+)+ can take a very long time on some inputs, so be careful where the input is long.
4Which flavor of regular expressions does this tester use?
It runs on the browser's JavaScript regular expression engine, so it checks patterns by JavaScript syntax.
Some syntax differs from Python, Java and PCRE, so check the differences when you move a pattern to another language.
Named group
JavaScript
(?<name>...)
Python
(?P<name>...)
Group reference in replace
JavaScript
$1, $<name>
Python
\1, \g<name>
Lookbehind
JavaScript
Variable length allowed
Python
Fixed length only
Item
JavaScript
Python
Named group
(?<name>...)
(?P<name>...)
Group reference in replace
$1, $<name>
\1, \g<name>
Lookbehind
Variable length allowed
Fixed length only
5What does each flag do?
Flags are options added after the pattern that change how it matches. In this tool you turn them on and off with checkboxes.
g
Meaning
Find all matches
i
Meaning
Ignore case
m
Meaning
^ and $ apply to each line
s
Meaning
The dot (.) also matches line breaks
u
Meaning
Handle Unicode characters properly
y
Meaning
Match only at the current position (sticky)
Flag
Meaning
g
Find all matches
i
Ignore case
m
^ and $ apply to each line
s
The dot (.) also matches line breaks
u
Handle Unicode characters properly
y
Match only at the current position (sticky)
6How do greedy and lazy matching differ?
Greedy matches as much as possible, and lazy matches as little as possible.
In <b>a</b> <b>b</b>, <.+> grabs everything from the first < to the last > as one block, while <.+?> grabs one tag at a time.
If a match is too broad, add a question mark to make it lazy or use a specific range such as [^>].
7How do I write a regex that finds only Hangul?
Complete Hangul syllables can be found with the range [가-힣], while stand-alone consonants and vowels must be specified separately.
Complete Hangul syllables
Pattern
[가-힣]+
Stand-alone consonants
Pattern
[ㄱ-ㅎ]+
Stand-alone vowels
Pattern
[ㅏ-ㅣ]+
Hangul, English letters and digits
Pattern
[가-힣a-zA-Z0-9]+
What to find
Pattern
Complete Hangul syllables
[가-힣]+
Stand-alone consonants
[ㄱ-ㅎ]+
Stand-alone vowels
[ㅏ-ㅣ]+
Hangul, English letters and digits
[가-힣a-zA-Z0-9]+
8Can I validate mobile numbers or emails with a regex?
It is useful for checking format, but it cannot tell whether the number or address really exists.
This tool's mobile-number example targets Korean numbers starting with 01, with or without hyphens.
It is hard to check every email case perfectly with a regex, so a simple format check followed by a confirmation email is the practical approach.
Before putting a validation regex into a service, test both valid and invalid examples in this tool.
9Does a date-format regex also reject February 31?
No, it does not, because a regex only looks at the shape.
(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01]) limits the month to 01–12 and the day to 01–31, so 2026-02-31 still passes.
Whether a date really exists must be checked separately in your program.
10How do I reorder parts using groups?
Referencing groups in the replace box lets you rearrange the order of a string.
For example, capture 2026-10-13 with named groups and replace it with $<day>/$<month>/$<year> to get 13/10/2026.
$1, $2
Meaning
First and second group
$<name>
Meaning
A named group
$&
Meaning
The whole matched text
$$
Meaning
A literal dollar sign
Notation
Meaning
$1, $2
First and second group
$<name>
A named group
$&
The whole matched text
$$
A literal dollar sign
11What if the regex freezes or runs too slowly?
This happens when nested repetition makes the number of attempts explode, commonly called catastrophic backtracking.
A pattern with repetition inside repetition, such as (a+)+$, is the classic example. This tool runs the regex in a separate worker and cuts it off after one second so the page does not freeze.
Avoid nesting repetition inside repetition.
Use a specific character range instead of a dot.
Narrow the scope with start and end anchors when needed.
When running regexes on user input on a server, set a time limit.
12How do I match special characters literally?
Put a backslash before a character that has a special meaning in regex to match it literally.
Characters with special meaning: . * + ? ^ $ { } ( ) | [ ] \
To match a literal dot, write \. instead.
To match a backslash, write it twice: \\.
Inside a character class [ ], most symbols are treated as ordinary characters.
13What jobs are better not done with regex?
For data with nested structure, a dedicated parser is safer than a regex.
Parsing a whole HTML document
Reading nested structures in JSON or XML
Checking that parentheses are balanced
Perfectly validating every rule of email addresses
The patterns and text you enter are processed only inside your browser. Try the common-pattern buttons and the copy-as-code feature too.
14What are some commonly used regex patterns?
Clicking a common-pattern button in this tool enters an example like the ones below straight away, and you can see the result in the sample text.
Korean mobile number
Pattern
01[016789]-?\d{3,4}-?\d{4}
5-digit postal code
Pattern
\b\d{5}\b
HEX color code
Pattern
#(?:[0-9a-f]{3}){1,2}\b
Repeated spaces
Pattern
[ \t]{2,}
Hangul only
Pattern
[가-힣]+
What to find
Pattern
Korean mobile number
01[016789]-?\d{3,4}-?\d{4}
5-digit postal code
\b\d{5}\b
HEX color code
#(?:[0-9a-f]{3}){1,2}\b
Repeated spaces
[ \t]{2,}
Hangul only
[가-힣]+
15What are lookahead and lookbehind?
Lookahead and lookbehind are syntax that checks whether a condition holds before or after a position without consuming characters.
For example, \d+(?=원) finds only numbers followed by 원 (won) and does not include 원 itself in the result.
(?=...)
Meaning
When ... follows
(?!...)
Meaning
When ... does not follow
(?<=...)
Meaning
When ... precedes
(?<!...)
Meaning
When ... does not precede
Syntax
Meaning
(?=...)
When ... follows
(?!...)
When ... does not follow
(?<=...)
When ... precedes
(?<!...)
When ... does not precede
16How can I check password rules with a regex?
Chaining several lookaheads lets you check conditions like containing both letters and digits at the same time.
This tool's password example is ^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*]{8,}$, which matches 8 or more characters with both letters and digits.
However, length and composition rules alone do not make a good password, so use it for reference only.
17How do I check line by line?
To apply start and end anchors to each line in multi-line text, turn on the m flag.
With m off, ^ and $ mean only the start and end of the whole text; with it on, they mean the start and end of each line.
Turn on m to check line by line.
Turn on s to make the dot (.) match line breaks too.
Turn on g to see all matches.
Turn on i to ignore case.
18How do I move the result into code?
Once the pattern and flags are set, the copy-as-code button takes them straight into your code.
Two forms are provided: slash notation (/pattern/flags) and new RegExp.
When passing a string to new RegExp, remember that backslashes must be written twice.
19What order should I use to check when matches differ from what I expect?
Splitting the pattern into small pieces and checking them one by one is the fastest way to debug.
First check that the flags (g, i, m) are right.
Check that you escaped special characters.
Wrap parts in parentheses to see which part is captured.
If it matches too broadly, narrow it with lazy matching or a specific character range.
Add examples to the sample text that should deliberately not match.
20Give me a quick overview of common regex symbols
At first, knowing just the symbols below lets you build most simple patterns.
\d
Meaning
One digit
Example
\d{3} is three digits
\w
Meaning
Letter, digit or underscore
Example
\w+ is a word
\s
Meaning
Whitespace character
Example
\s+ is repeated whitespace
+
Meaning
One or more
Example
a+ matches a, aa, aaa
*
Meaning
Zero or more
Example
ab* matches a, ab, abb
?
Meaning
Zero or one
Example
colou?r matches color, colour
|
Meaning
Or
Example
cat|dog
Symbol
Meaning
Example
\d
One digit
\d{3} is three digits
\w
Letter, digit or underscore
\w+ is a word
\s
Whitespace character
\s+ is repeated whitespace
+
One or more
a+ matches a, aa, aaa
*
Zero or more
ab* matches a, ab, abb
?
Zero or one
colou?r matches color, colour
|
Or
cat|dog
21How do I shrink multiple spaces into one?
Use [ \t]{2,} as the pattern and a single space as the replacement, and runs of two or more spaces become one space.
Turn on the g flag to replace throughout the text, and when you turn on the replace feature in this tool the result appears right below.
Pattern: [ \t]{2,}
Replacement: one space
Flag: g
To shrink line breaks too, use \s{2,} but check that paragraph breaks do not disappear.
22How do I keep only the digits of a phone number?
Find the characters that are not digits and replace them with nothing.
With the pattern \D, the g flag on and an empty replacement, 010-1234-5678 becomes 01012345678.
To add hyphens back, split the number into groups and replace with something like $1-$2-$3.
Replace results do not affect the original, so feel free to test as many times as you like.
23Is there a good order for learning regex when it feels hard?
Rather than memorizing everything at once, it is faster to modify common patterns yourself in this tool.
Start with single characters and repetition (+, *, ?, {n,m}).
Try character classes ([abc], \d, \w).
Understand start and end (^, $) and the word boundary (\b).
Practice groups and replacement ($1).
Finally try lookahead and named groups.
24How do I write a regex that finds one of several words?
List the candidates with the vertical bar, and combine \b with a group if you want to match whole words.
For example, \b(?:사과|배|포도)\b finds only cases where one of these three words appears on its own.
Adding ?: after the opening parenthesis stops the group from being captured separately, so numbering stays clean in replacements.
25How do I add thousands separators to a number?
Use a lookahead to find the positions followed by groups of three digits and replace them with a comma.
With the pattern \B(?=(?:\d{3})+(?!\d)), the g flag on and a comma as the replacement, 1234567 becomes 1,234,567.
Numbers with a decimal point need separate handling so that it applies only to the integer part.
26How do I see match positions and group information?
This tool marks matched parts in color and lists each match's position and group contents.
It shows up to the first 1,000 matches and also tells you the total count.
Check parenthesized groups by number and named groups by name.
With replace on, the replaced text appears right below.
Changing the pattern updates results immediately, so trial and error is quick.