한국어
Home › Guides › Developer

Regex basics and common patterns you can test right away

Developer · 6 min read

A regular expression (regex) describes a text pattern in a short expression so you can find or replace it. Filtering error lines in a log, checking whether input looks like an email, reformatting dates in bulk: each takes only a few characters. The symbols look cryptic at first, but a handful covers most everyday tasks.

Core symbols

SymbolMeaningExample
.Any single charactera.c matches abc, a1c
\dOne digit\d\d matches 07, 42
\wLetter, digit or underscore\w+ matches user_1
\sOne whitespace characterspace, tab, line break
[abc]One of the listed characters[A-Z] is one capital letter
* + ?0 or more, 1 or more, 0 or 1\d+ is one or more digits
{n,m}Repeat n to m times\d{3,4}
^ $Start and end of a line^\d+$ is a digits-only line
( )Group and captureReusable in replacements

To match a symbol literally, such as ., ? or (, put a backslash in front of it. A literal dot is \..

Common patterns

Formats with complex rules, like email, are hard to validate perfectly with regex. Use the pattern above to filter things that roughly look like an email, and confirm real addresses with a verification email.

Build it while testing

  1. Paste real sample data into the test text box of the Regex Tester below.
  2. Write the pattern piece by piece and watch the highlighted matches.
  3. Check captured groups in the group table.
  4. Preview replacements using $1, $2 in the replace box.
Regex TesterTest matches and replacements live
Open tool

Flags worth knowing

Replacement example: changing a date format

Search for (\d{4})-(\d{2})-(\d{2}) and replace with $2/$3/$1, and 2026-11-11 becomes 11/11/2026. Groups are numbered in the order of their opening parentheses.

Regex syntax differs slightly between programming languages. This tool uses JavaScript rules, so double-check in your target language before using a pattern elsewhere.

Tools in this article

Regex TesterTest matches and replacements live
Open tool