Regex
June 29, 2026 ยท View on GitHub
Regular expressions are a core skill for any half decent programmer.
There is a saying:
"The plural of regex is regrets"
But it would be more accurate to say:
"Not learning regex properly leads to regrets"
One regex, many regex... on my GitHub.
I use them extensively in languages from Python and Perl to Java/Scala/Groovy and even in many shell scripts in Bash for grep, sed & awk.
- Online Regex Testing
- PCRE vs BRE vs ERE
- BRE - Basic Regular Expression
- ERE - Extended Regular Expressions
- Core Reading
- Library of Regex in Perl
- Library of Regex in Python
- Library of Regex in Bash
- Examples of Real-world Regex Used Extensively
- Meme
Online Regex Testing
Sed Regex Testing
Test your sed regex here:
PCRE vs BRE vs ERE
PCRE - Perl Compatible Regular Expressions
The gold standard from Perl which most popular languages aspire to
GNU grep has a grep -P switch to use PCRE but beware it's not portable. It won't work on BSD based systems like macOS.
On Mac you can install coreutils to get the better GNU Grep
brew install coreutils
but then you'll have to use the ggrep command instead.
Your shell scripts will have to figure our if they're on Mac and override the grep command (examples in DevOps-Bash-tools repo).
BRE - Basic Regular Expression
This is the neutered regex that old grep uses.
ERE - Extended Regular Expressions
Slightly better than BRE but still weak & awkward compared to PCRE.
Don't support back references.
Grep on most systems can support EREs via the grep -E switch.
Awk also uses EREs.
Core Reading
Library of Regex in Perl
PCRE regex:
Library of Regex in Python
PCRE regex:
Library of Regex in Bash
BRE / ERE Regex:
Examples of Real-world Regex Used Extensively
PCRE regex - see especially anonymize.py / anonymize.pl in these repos among many other scripts:
HariSekhon/DevOps-Python-tools
Meme
Googling for the Regex

Expert Regex
