Regular Expressions (Perl Style)
UltraEdit/UEStudio now support Perl style regular expressions using the Boost C++ Libraries. The Perl regular expression syntax is based on that used by the programming language Perl.
Perl Regular Expression Syntax
In Perl regular expressions, all characters match themselves except for the following special characters:
The single character '.' when used outside of a character set will match any single character.
A '^' character shall match the start of a line.
A '$' character shall match the end of a line.
A section beginning ( and ending ) acts as a marked sub-expression. Whatever matched the sub-expression is split out in a separate field by the matching algorithms. Marked sub-expressions can also repeated, or referred to by a back-reference.
The | operator will match either of its arguments, so for example: abc|def will match either " abc" or "def".
Parenthesis can be used to group alternations, for example: ab(d|ef) will match either of " abd" or " abef".
Empty alternatives are not allowed (these are almost always a mistake), but if you really want an empty alternative use (?:) as a placeholder, for example:
"| abc" is not a valid expression, but
"(?:)| abc" is and is equivalent, also the expression:
"(?: abc)??" has exactly the same effect.
A character set is a bracket-expression starting with [ and ending with ], it defines a set of characters, and matches any single character that is a member of that set.
A bracket expression may contain any combination of the following:
For example [ abc], will match any of the characters 'a', 'b', or 'c'.
For example [ a-c] will match any single character in the range 'a' to 'c'. By default, for POSIX-Perl regular expressions, a character x is within the range y to z, if it collates within that range; this results in locale specific behavior.
If the bracket-expression begins with the ^ character, then it matches the complement of the characters it contains, for example [^ a-c] matches any character that is not in the range a-c.
An expression of the form [[:name:]] matches the named character class "name", for example [[:lower:]] matches any lower case character. The following character class names are always supported:
Any special character preceded by an escape shall match itself. The following escape sequences are also supported:
Escapes matching a specific character
The following escape sequences are all synonyms for single characters:
"Single character" character classes
Any escaped character x, if x is the name of a character class shall match any character that is a member of that class, and any escaped character X, if x is the name of a character class, shall match any character not in that class. The following are supported by default:
The following escape sequences match the boundaries of words:
For further information/options please see the Boost Libraries Perl Regular Expression syntax pages.
Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http:// www.boost.org/LICENSE_1_0.txt).
|Posted - Thu, Oct 20, 2011 7:39 AM. This article has been viewed 4853 times.|
|Online URL: http://www.ultraedit.com/help/article/regular-expressions-perl-style-1736.html|
Powered by PHPKB Knowledge Base Software