|Instantly and accurately analyze and test any regular expression with RegexBuddy. Save yourself the headache of figuring out the differences between regex flavors. RegexBuddy knows all the regex features and regex flavors listed in this reference. RegexBuddy also explains and emulates many more subtle differences and idiosyncrasies that are omitted here to keep this reference readable. Get your own copy of RegexBuddy now|
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.
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.
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 allow you to use common sets of characters quickly. You can use shorthands on their own or as part of character classes.
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.
Quantifiers allow you to repeat an item a specific or an unlimited number of times.
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.
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.
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.
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! Credit cards, PayPal, and Bitcoin gladly accepted.
Page URL: http://www.regular-expressions.info/refflavors.html
Page last updated: 24 November 2016
Site last updated: 26 January 2017
Copyright © 2003-2017 Jan Goyvaerts. All rights reserved.
|Table of Contents|
|Capturing Groups & Backreferences|
|Named Groups & Backreferences|
|Recursion & Balancing Groups|
|Matched Text & Backreferences|
|Context & Case Conversion|
|Regular Expressions Quick Start|
|Regular Expressions Tutorial|
|Replacement Strings Tutorial|
|Applications and Languages|
|Regular Expressions Examples|
|Regular Expressions Reference|
|Replacement Strings Reference|
|About This Site|
|RSS Feed & Blog|