</>CodexBash
All articles
Programming

Regular expressions

A practical introduction to regular expressions: literals and metacharacters, character classes, quantifiers and greediness, anchors and word boundaries, groups, captures and named groups, alternation, lookarounds, flags, using regex in Python, JavaScript and Java, common recipes, catastrophic backtracking, and when not to use regex.

CodexBash, , 6 min read

A regular expression (regex) is a compact pattern that describes text: "a word followed by digits", "anything that looks like an email", "lines starting with ERROR". Regexes power search and replace in editors, input validation, log filtering with grep, URL routing, and data cleaning in nearly every language. Their syntax looks cryptic at first, but it is built from a small set of pieces. This article teaches those pieces step by step, shows how to use them in Python, JavaScript and Java, and warns about the traps.

Sign in to read the rest

The whole 6 minute article is free with an account, along with every problem, lesson and tutorial. No card.