Regex ProTips

Of the many tired sayings uttered by professional developers, this one about regular expressions is actually(mostly) true:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.

popular quote by Jamie Zawinski

Here are some ways to mitigate the pain of regex-ing and make matching fun again.

Use Online tool

There are a number of tools online that will let you build, test, and debug regex. For top-tier experience, check out Doppler’s regex101.

du-regex101-brows-demo.gif

Read a written guide

For a well-condensed guide that will expose you to Regex characteristics and slight differences in how they are used across languages, see : Regular-Expressions.info

For JavaScript focused development, see MDN’s Guide for Regular expressions.

EREs like PCRE vs BRE

When learning, be aware of that there are multiple flavors of Regular Expression capabilities and syntax.

For example, a regex written to work with Perl Compatible Regular Expression library, might not work with other Extended Regular Expressions. For more authoritative, see. BRE vs ERE (sed, a stream editor) – GNU.org

The wide compatibility for PCRE so that makes it a safe and versatile syntax to invest time learning.

0 responses to “Regex ProTips”