Tutorials

Regular Expressions: A Practical Developer Tutorial

CodeUtilityKit Team··10 min read

Regular Expressions for Developers

Regular expressions (regex) are powerful pattern-matching tools used in nearly every programming language.

Basic Syntax

  • . (dot) — Any character
    • — 0 or more repetitions
    • — 1 or more repetitions
  • ? — 0 or 1 repetitions
  • ^ — Start of string
  • $ — End of string
  • [] — Character class
  • () — Capturing group

Common Patterns

Email: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$ UUID v4: ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ IP Address: ^(\d{1,3}.){3}\d{1,3}$

Flags

  • g — Global (find all matches)
  • i — Case insensitive
  • m — Multiline
  • s — Dot matches newlines

Try Regex Tester

Use our free Regex Tester to test patterns with real-time match highlighting.

CU

CodeUtilityKit Team builds free, privacy-first developer tools that run entirely in your browser. Every guide is written and reviewed by developers who use these tools daily.