Regular expressions
Regular expressions (or “regexes”) are sequences of characters used to find matches in text. For example, [a-z]+ matches any text made of lowercase characters a to z, or [0-9]+\.[0-9]+ matches any decimal number like 42.1.
2 articles
What does \d match in a regex?
It’s more complicated than I thought.
Treat regular expressions as code, not magic
Regexes have a reputation for being unreadable monsters, but it doesn’t have to be that way.
2 notes
The caret anchor (
^) matches differently in Python and RubyYou can reset the start of a regex in Ruby
The
\Kescape is the “Match-Reset Anchor”, which resets the start of the reported match, and skip any previously consumed characters.