taptools/blog/Regex Guide
RegexMay 3, 2026 · 8 min read

Regular Expressions Guide for Developers

Regular expressions (regex) are powerful patterns for searching and manipulating text. This practical guide covers the most useful patterns with real-world examples.

What is Regex?

A regular expression is a sequence of characters that defines a search pattern. Regex is supported in virtually every programming language and is used for:

  • Validating email addresses, phone numbers, URLs
  • Finding and replacing text
  • Extracting data from strings
  • Parsing log files and configuration files

Basic Regex Syntax

PatternMatchesExample
.Any charactera.c matches "abc", "axc"
*0 or moreab* matches "a", "ab", "abb"
+1 or moreab+ matches "ab", "abb"
?0 or 1ab? matches "a", "ab"
^Start of string^Hello matches "Hello world"
$End of stringworld$ matches "Hello world"
\dAny digit 0-9\d+ matches "123"
\wWord character\w+ matches "hello"
\sWhitespace\s matches space, tab
[abc]a, b, or c[aeiou] matches vowels
[^abc]Not a, b, or c[^0-9] matches non-digits

Common Regex Patterns

Email address

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

Matches: hello@taptools.dev

URL

https?:\/\/[^\s]+

Matches: https://taptools.dev

Phone number

\+?[1-9]\d{1,14}

Matches: +1234567890

Date (YYYY-MM-DD)

\d{4}-\d{2}-\d{2}

Matches: 2026-05-01

IP address

\b(?:\d{1,3}\.){3}\d{1,3}\b

Matches: 192.168.1.1

Regex Flags

gGlobalFind all matches, not just the first
iInsensitiveCase insensitive matching
mMultiline^ and $ match start/end of each line
sDotAllDot matches newlines too

Test regex patterns instantly

Our regex tester shows matches highlighted in real time as you type.

Open Regex Tester →

Related articles