Tutorials
Regular Expressions: A Practical Developer Tutorial
Marcus BrennanΒ·Β·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.
MB
Marcus Brennan writes for CodeUtilityKit, where the 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.