
| Easily create and understand regular expressions today. Compose and analyze regex patterns with RegexBuddy's easy-to-grasp regex blocks and intuitive regex tree, instead of or in combination with the traditional regex syntax. Developed by the author of this website, RegexBuddy makes learning and using regular expressions easier than ever. Get your own copy of RegexBuddy now, and get a FREE printable PDF version of the regex reference on this website. |
| .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 |
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!
Page URL: http://www.Regular-Expressions.info/refext.html
Page last updated: 01 August 2007
Site last updated: 06 June 2008
Copyright © 2003-2008 Jan Goyvaerts. All rights reserved.
| Books |
| Teach Yourself Reg. Expr. |
| Mastering Regular Expr. |
| Java Regular Expressions |
| Oracle Regular Expr. |
| Regular Expr. Pocket Ref. |
| Regular Expr. Recipes |
| Regex Recipes for Windows |
| Regex Reference |
| Basic Regex Syntax |
| Advanced Regex Syntax |
| Unicode-Specific Syntax |
| Flavor-Specific Syntax |
| Flavor Comparison |
| Replacement Syntax |
| More Information |
| Introduction |
| Quick Start |
| Tutorial |
| Tools and Languages |
| Examples |
| Books |
| Reference |
| Print PDF |
| About This Site |
| RSS Feed |
| PowerGREP 3 |
| Use regular expressions to search through large numbers of text and binary files, such as source code, correspondence, server or system logs, reference texts, archives, etc. Quickly find the files you are looking for, or extract the information you need. Look through just a handful of files, or thousands of files and folders. |
| Perform comprehensive text and binary replacement operations for easy maintenance of websites, source code, reports, etc. Preview replacements before modifying files, and stay safe with flexible backup and undo options. |
| Work with plain text files, Unicode files, binary files, files stored in zip archives, and even MS Word documents, Excel spreadsheets and PDF files. Runs on Windows 98, ME, NT4, 2000, XP & Vista. |
| More information |
| Download PowerGREP now |