Back to search

Regular expressions: search vs match, groups, and substitution

Python regular expressions help when patterns are simpler to express declaratively than with manual loops.

Python Medium Theory

Regular expressions: search vs match, groups, and substitution

Python regular expressions help when patterns are simpler to express declaratively than with manual loops.

  • `search` scans anywhere, `match` starts at the front
  • Groups capture subpatterns
  • `sub` performs replacements

Regular expressions: search vs match, groups, and substitution