Skip to content
Local Only Dev Tools
7 min read

Regex Basics for Developers

A practical introduction to patterns, groups, anchors and flags.

Quick answer

A regex describes a text pattern. Anchors, groups and quantifiers control where and how often it matches.

Patterns and anchors

A regular expression describes a pattern of text. Anchors ^ and $ match the start and end of a line or string, while \d, \w and \s match digit, word and whitespace characters.

Groups and quantifiers

Parentheses create capture groups you can read back from a match. Quantifiers like *, +, ? and {n,m} control how many times the previous token repeats.

  • •* means zero or more
  • •+ means one or more
  • •? means zero or one

Flags

g finds all matches, i ignores case, m makes anchors work per line, and s lets the dot match newlines. Test flags live against realistic sample text.

Common mistakes

  • •Forgetting to escape special characters
  • •Using greedy quantifiers by accident
  • •Omitting the g or i flag

When to use this

  • •Validating input formats
  • •Extracting values from logs
  • •Searching large text files

Try it yourself

Test regular expressions live against sample text with flags, matches and capture groups. Runs locally in your browser.

Open Regex Tester