The introduction explains how to read the regular expressions reference tables.
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. Nnn-printable characters are easier to enter using control character escapes or hexadecimal escapes.
Basic regular expression features supported by most regular expression flavors.
Character Classes, Shorthands, 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. 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. 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.
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 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 such as branch reset groups, atomic groups, lookaround, and conditionals.
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.
Did this website just save you a trip to the bookstore? Please make a donation to support this site, and you'll get a lifetime of advertisement-free access to this site!
| Quick Start | Tutorial | Tools & Languages | Examples | Reference | Book Reviews |
| Introduction | Table of Contents | Quick Reference | Characters | Basic Features | Character Classes | Anchors | Word Boundaries | Quantifiers | Unicode | Capturing Groups & Backreferences | Named Groups & Backreferences | Special Groups | Mode Modifiers | Recursion & Balancing Groups |
| Characters | Matched Text & Backreferences | Context & Case Conversion | Conditionals |
Page URL: http://regular-expressions.mobi/refflavors.html
Page last updated: 19 December 2013
Site last updated: 25 October 2016
Copyright © 2003-2016 Jan Goyvaerts. All rights reserved.