Utilumo
LightDarkSystem
Explainer1 min readUpdated June 29, 2026

Regular expressions explained

Short answer

A regular expression (regex) is a small pattern language for matching text. You describe what the text should look like using characters, special symbols, and repetition rules, and the engine finds or replaces every match.

The building blocks

Most of a regex is literal characters that match themselves. The power comes from a handful of special pieces that describe sets of characters, how often they repeat, and where they sit.

  • . matches any single character except a newline
  • \d matches a digit, \w a word character, \s whitespace
  • [abc] matches one of a, b, or c; [a-z] matches a range
  • * zero or more, + one or more, ? zero or one
  • {2,4} matches between two and four repetitions
  • ^ anchors to the start, $ to the end of the line
^[\w.+-]+@[\w-]+\.[a-z]{2,}$
A simple email-like pattern
Try it: Regex TesterTest a pattern against sample text and see every match highlighted, locally.Open tool

Groups and alternation

Parentheses ( ) create a group you can repeat or capture, and the pipe | means 'or'. So (cat|dog)s? matches cat, cats, dog, or dogs. Captured groups let you pull pieces out of a match or reuse them in a replacement.

Escape special charactersCharacters like . * + ? ( ) [ ] { } ^ $ | \ have special meaning. To match one literally, put a backslash in front of it, for example \. to match a real dot.

Common mistakes

  • Forgetting that . matches almost anything, which makes patterns too greedy.
  • Not anchoring with ^ and $ when you need to match the whole string.
  • Trying to parse HTML or deeply nested formats with regex, which it is not built for.

References

Questions

What is the difference between * and +?

Both repeat the preceding item, but * allows zero matches while + requires at least one. So a* matches an empty string, whereas a+ needs at least one a.

Are regular expressions the same in every language?

The core syntax is shared, but flavors differ in advanced features and flags. The patterns here use the common syntax shared by JavaScript, Python, and most modern engines.

Does this send my data anywhere?

No. Utilumo's developer tools parse and transform input inside the browser tab. Nothing is uploaded, stored, or logged.

Keep reading