| Tutorial | Tools & Languages | Examples | Books & Reference |
| Regular Expr. Cookbook | Teach Yourself Reg. Expr. | Mastering Regular Expr. | Java Regular Expressions | Oracle Regular Expr. | Regular Expr. Pocket Ref. | Regular Expr. Recipes | Regex Recipes for Windows |
| Basic Regex Syntax | Advanced Regex Syntax | Unicode-Specific Syntax | Flavor-Specific Syntax | Flavor Comparison | Replacement Syntax |
| .NET Syntax for Named Capture and Backreferences | ||
|---|---|---|
| Syntax | Description | Example |
| (?<name>regex) | Round brackets group the regex between them. They capture the text matched by the regex inside them that can be referenced by the name between the sharp brackets. The name may consist of letters and digits. | |
| (?'name'regex) | Round brackets group the regex between them. They capture the text matched by the regex inside them that can be referenced by the name between the single quotes. The name may consist of letters and digits. | |
| \k<name> | Substituted with the text matched by the capturing group with the given name. | (?<group>abc|def)=\k<group> matches abc=abc or def=def, but not abc=def or def=abc. |
| \k'name' | Substituted with the text matched by the capturing group with the given name. | (?'group'abc|def)=\k'group' matches abc=abc or def=def, but not abc=def or def=abc. |
| (?(name)then|else) | If the capturing group "name" took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group "name" did not take part in the match, the "else" part must match for the overall regex to match. | (?<group>a)?(?(group)b|c) matches ab, the first c and the second c in babxcac |
| Python Syntax for Named Capture and Backreferences | ||
| Syntax | Description | Example |
| (?P<name>regex) | Round brackets group the regex between them. They capture the text matched by the regex inside them that can be referenced by the name between the sharp brackets. The name may consist of letters and digits. | |
| (?P=name) | Substituted with the text matched by the capturing group with the given name. Not a group, despite the syntax using round brackets. | (?P<group>abc|def)=(?P=group) matches abc=abc or def=def, but not abc=def or def=abc. |
| XML Character Classes | ||
| Syntax | Description | Example |
| \i | Matches any character that may be the first character of an XML name, i.e. [_:A-Za-z]. | |
| \c | \c matches any character that may occur after the first character in an XML name, i.e. [-._:A-Za-z0-9] | \i\c* matches an XML name like xml:schema |
| \I | Matches any character that cannot be the first character of an XML name, i.e. [^_:A-Za-z]. | |
| \C | Matches any character that cannot occur in an XML name, i.e. [^-._:A-Za-z0-9]. | |
| [abc-[xyz]] | Subtracts character class "xyz" from character class "abc". The result matches any single character that occurs in the character class "abc" but not in the character class "xyz". | [a-z-[aeiou]] matches any letter that is not a vowel (i.e. a consonant). |
| POSIX Bracket Expressions | ||
| Syntax | Description | Example |
| [:alpha:] | Matches one character from a POSIX character class. Can only be used in a bracket expression. | [[:digit:][:lower:]] matches one of 0 through 9 or a through z |
| [.span-ll.] | Matches a POSIX collation sequence. Can only be used in a bracket expression. | [[.span-ll.]] matches ll in the Spanish locale |
| [=x=] | Matches a POSIX character equivalence. Can only be used in a bracket expression. | [[=e=]] matches e, é, è and ê in the French locale |
| Tutorial | Tools & Languages | Examples | Books & Reference |
| Regular Expr. Cookbook | Teach Yourself Reg. Expr. | Mastering Regular Expr. | Java Regular Expressions | Oracle Regular Expr. | Regular Expr. Pocket Ref. | Regular Expr. Recipes | Regex Recipes for Windows |
| Basic Regex Syntax | Advanced Regex Syntax | Unicode-Specific Syntax | Flavor-Specific Syntax | Flavor Comparison | Replacement Syntax |
Page URL: http://regular-expressions.mobi/refext.html
Page last updated: 17 June 2009
Site last updated: 02 December 2010
Copyright © 2003-2012 Jan Goyvaerts. All rights reserved.