Skip to content
TopicTracker
From johndcook.comView original
TranslationTranslation

Regular expressions that work “everywhere”

The article discusses how regular expression implementations vary across tools, with different feature sets and syntax. The author, having learned regex in Perl's maximalist environment, notes the frustration when features expected do not work elsewhere. The post likely covers strategies for writing portable regex patterns.

Background

Regular expressions ("regex") are patterns used to search and manipulate text — think of them as a mini programming language for finding patterns like email addresses or phone numbers inside larger documents. The problem: every programming language, text editor, and command-line tool has its own slightly different regex engine, so a pattern that works in Perl might break in Python or grep. This post by John D. Cook (a long-time math-and-software blogger) likely lists which regex features are safe to use across almost all environments (the "common subset") versus those you should avoid unless you know your specific tool supports them. It matters because engineers waste significant time debugging cross-platform regex failures.

Related stories

  • The article discusses the challenge of writing regular expressions that work consistently across different programming languages and regex engines. It highlights subtle differences in syntax and behavior between common implementations, such as those in Perl, Python, and JavaScript, and offers strategies for writing more portable regex patterns.

  • The article discusses the challenges of writing regular expressions that work consistently across different programming languages and environments, noting that while regex syntax is similar, subtle differences in implementation, features, and behavior often break portability. It offers strategies for crafting more portable regex patterns.