Quick Start
Tutorial
Tools & Languages
Examples
Reference
Book Reviews
Regex Reference
Introduction
Table of Contents
Quick Reference
Characters
Basic Features
Character Classes
Shorthands
Anchors
Word Boundaries
Quantifiers
Unicode
Capturing Groups & Backreferences
Named Groups & Backreferences
Special Groups
Mode Modifiers
Recursion & Balancing Groups
Replacement Reference
Characters
Matched Text & Backreferences
Context & Case Conversion
Conditionals
More on This Site
Introduction
Regular Expressions Quick Start
Regular Expressions Tutorial
Replacement Strings Tutorial
Applications and Languages
Regular Expressions Examples
Regular Expressions Reference
Replacement Strings Reference
Book Reviews
Printable PDF
About This Site
RSS Feed & Blog
RegexBuddy—Better than a regular expression reference!

Regular Expressions Reference Table of Contents

Introduction

The introduction explains how to read the regular expressions reference tables.

Quick Reference

Use this quick reference if you’ve seen some syntax in somebody else’s regex and you have no idea what feature that syntax is for. Use the full reference tables listed below if you know what feature you want but don’t remember the syntax.

Literal Characters, Special Characters, and Non-Printable Characters

Most characters match themselves. Some characters have special meanings and must be escaped. Non-printable characters are easier to enter using control character escapes or hexadecimal escapes.

Basic Features

Basic regular expression features supported by most regular expression flavors.

Character Classes and Character Class Operators

A character class or character set matches a single character out of several possible characters, consisting of individual characters and/or ranges of characters. A negated character class matches a single character not in the character class. Character class subtraction and intersection allow you to match one character that is present in one set of characters and not/also present in another set of characters.

Shorthand Character Classes

Shorthand character classes allow you to use common sets of characters quickly. You can use shorthands on their own or as part of character classes.

Anchors

Anchors are zero-length. They do not match any characters, but rather a position. There are anchors to match at the start and end of the subject string, and anchors to match at the start and end of each line.

Word Boundaries

Word boundaries are like anchors, but match at the start of a word and/or the end of a word.

Repetition Using Various Quantifiers

Quantifiers allow you to repeat an item a specific or an unlimited number of times.

Unicode Characters and Properties

If your regular expression flavor supports Unicode, then you can use special Unicode regex tokens to match specific Unicode characters, or to match any character that has a certain Unicode property or is part of a particular Unicode script or block.

Capturing Groups and Backreferences

By placing parentheses around part of the regex, you tell the engine to treat that part as a single item when applying quantifiers or to group alternatives together. Parentheses also create capturing groups allow you to reuse the text matched by part of the regex. Backreferences to capturing groups match the same text that was previously matched by that capturing group, allowing you to match patterns of repeated text.

Named Groups and Backreferences

Regular expressions that have multiple groups are much easier to read and maintain if you use named capturing groups and named backreferences.

Special Groups

Special groups such as branch reset groups, atomic groups, lookaround, and conditionals.

Mode Modifiers

Change matching modes such as “case insensitive” for specific parts of the regular expression.

Recursion, Subroutine Calls, and Balancing Groups

Subroutine calls allow you to write regular expressions that match the same constructs in multiple places without having to duplicate parts of your regular expression. Recursion and balancing groups allow you to match arbitrarily nested constructs.