Skip to content

Regular expression

September 29, 2023
February 26, 2015

Regular expression is a formal language for pattern matching. Different languages supports different feature sets and have different syntaxes, see summary here.

The true power of regular expressions

The Regular Expression Edition - by Guest Contributor - Why is this interesting? history
Regular Expressions - Computerphile - YouTube

Learning

Learn regular expressions in about 55 minutes
Regex Learn - Step by step, from zero to advanced.
Regex Tutorial—From Regex 101 to Advanced Regex
RegexOne - Learn Regular Expressions
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
Tech Stuff - Regular Expressions - A Gentle User Guide and Tutorial
zeeshanu/learn-regex: Learn regex the easy way
Learn Regular Expressions in 20 Minutes | Tutorialzine
RegexLearn And Other RegEx Resources

Introduction to Regular Expressions - YouTube
Best of Fluent 2012: /Reg(exp){2}lained/: Demystifying Regular Expressions - YouTube

Writing The Perfect RGB Regex And Failing

VerbalExpressions ♥ Open Source

[^abc], which is character by character not a or b or c,
or negative lookahead: a(?!b), which is a not followed by b
or negative lookbehind: (?<!a)b, which is b not proceeded by a

.NET Regex: \d is different from [0-9] - Meziantou's blog

Visualizer

Use these visualizers to help you understand the regexes.

Debuggex (JavaScript, Python, PCRE)

Regulex:JavaScript Regular Expression Visualizer. source
Regexper (JavaScript)
Regex for playground - IHateRegex

Tester

These highlight matches in input test string.

Online regex tester and debugger: JavaScript, Python, PHP, and PCRE (with explanation)
RegExr: Learn, Build, & Test RegEx (JavaScript, PCRE) (with explanation)
RegExr: Learn, Build, & Test RegEx (JavaScript)
Regex Builder (JavaScript)
Regex Tester - Javascript, PCRE, PHP
RegExp playground (JavaScript)
ReFiddle (JavaScript, Ruby, .Net)
Regex Tester and Debugger Online - Javascript, PCRE, PHP
Python Regex Tool
Rubular: a Ruby regular expression editor and tester

#perfmatters

Five Invaluable Techniques to Improve Regex Performance
Runaway Regular Expressions: Catastrophic Backtracking
Regular expression (regex) performance: The fundamental guide — / org.site-reliability — Medium
Optimizing regular expressions in Java | JavaWorld
What you should know about JavaScript regular expressions

Flagrant Badassery » Performance of Greedy vs. Lazy Regex Quantifiers
Flagrant Badassery » Capturing vs. Non-Capturing Groups
Flagrant Badassery » Regexes in Depth: Advanced Quoted String Matching
Flagrant Badassery » Matching Nested Constructs in JavaScript
Flagrant Badassery » Matching Nested Constructs in JavaScript, Part 2
Flagrant Badassery » Regex Recursion (Matching Nested Constructs)

POSIX ERE

Tech Stuff - Regular Expressions - A Gentle User Guide and Tutorial
Regular expression - Wikipedia, the free encyclopedia
The conditional expression [Bash Hackers Wiki]
Patterns and pattern matching [Bash Hackers Wiki]

Bash double bracket regex comparison using negative lookahead error return 2 - Stack Overflow

Perl (PCRE)

I think Perl's regex is the most expressive and portable (via wide support of Perl Compatible Regular Expressions).

PCRE - Perl Compatible Regular Expressions
PCRE Regular Expression Cheatsheet - Debuggex

google/re2: RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.

grep support PCRE with -P option.

man 3 pcrepattern
man 3 pcresyntax
man 1 perlre

perlre - perldoc.perl.org
perlretut - perldoc.perl.org
Perl Regular Expression Syntax - 1.44.0

rust-lang/regex: An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.

echo "123\n456" | perl -n -e '/[15](\d+)/ && print "$1\n"'

RE2

Implementing Regular Expressions
google/re2: RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
Syntax · google/re2 Wiki

Regular Expression Matching Can Be Simple And Fast
Regular Expression Matching: the Virtual Machine Approach
Regular Expression Matching in the Wild
there are no regular expressions that are pathological for the Thompson NFA implementation (used in Go)

JavaScript

JavaScript's Regex does not have look behind and named captures. Use XRegExp if you need them.

Upcoming Regular Expression Features | Web | Google Developers Chrome begin to support these features in 2018

Cover - JavaScript RegExp
JavaScript Regular Expression Cheatsheet - Debuggex

JavaScript: an overview of the regular expression API
The flag /g of JavaScript’s regular expressions

RegExps — Centralized place for community-driven collections of RegExp patterns and tools that can make our life easier.

hokein/Automata.js converts Regex to FSM
jwerle/sregex
dtao/simplex

VerbalExpressions/JSVerbalExpressions

Python

re — Regular expression operations — Python 3 documentation
Regular Expression HOWTO — Python 3 documentation
Python regex: How to use Python regular expressions | InfoWorld
Python Regular Expressions - Google for Education — Google Developers

Python Regular Expression Cheatsheet - Debuggex
The Ultimate Guide to using the Python regex module
Cover - Python re(gex)?

Regular Expressions: Regexes in Python (Part 1) – Real Python
Regular Expressions: Regexes in Python (Part 2) – Real Python

python - Named regular expression group "(?P<group_name>regexp)": what does "P" stand for? - Stack Overflow

Kodos - The Python Regex Debugger
Google Code Archive - kiki-re
Pythex: a Python regular expression editor

Welcome to pregex’s documentation!
manoss96/pregex: PRegEx - Programmable Regular Expressions

Go

regexp package - regexp - pkg.go.dev

golang's regexp and re2
Regexp tutorial and cheat sheet · YourBasic Go
A deep dive into regular expressions with Golang - LogRocket Blog

oriser/regroup: Match regex group into go struct using struct tags and automatic parsing

Find all named match groups and return as a map keyed by the group name like Python's match.groupdict()