"""rxb, a simple regular expression builder (by Ka-Ping Yee, 20 Sept 1996) From an idea by Greg Ewing, on comp.lang.python. This module encapsulates the construction and functionality of regular expressions in a class named 'Pattern'. To build 'Pattern's, use the functions and constants in this module; you should not need to instance the 'Pattern' class directly unless you are actually supplying a real (awk-style) regular expression. You can concatenate 'Pattern' instances using the '+' operator or repeat them using the '*' operator with a number. The available functions are: exactly() :: exactly the string! anybut() :: any text but the string member(, , ...) :: any single char mentioned nonmember(, , ...) :: any single char not mentioned maybe() :: possibly one occurrence some() :: one or more occurrences any() :: zero or more occurrences either(, , ...) :: one of the alternatives label(, ) :: label a subgroup for later For 'label' you can also use the alternate, more concise syntax label.() The first four functions only accept literal strings. The rest all accept either literals or 'Pattern's otherwise created by this module. Note that 'exactly()' is necessary only if used alone, since any string will be converted from a literal to a 'Pattern' by any of the other operations (including '+'). 'member()' and 'nonmember()' accept any literal characters or strings of characters among their arguments, as well as the special constants 'letters', 'digits', 'hexdigits', 'wordchars', and 'whitespace' from this module. It doesn't make sense to use 'non'-anything in a set of chars, so don't. :) You can also give to 'member()' or 'nonmember()' a sequence created using 'chrange(, )'. For your convenience, the following 'Pattern' constants are also available: letter, letters :: any small or capital letter digit, digits :: any digit wordchar, wordchars :: letter, digit, or underscore hexdigit, hexdigits :: any hexadecimal digit whitespace :: space, return, newline, tab anychar, anychars :: any single character nonletter, nondigit, nonwordchar, nonhexdigit, or nonwhitespace :: any char other than the indicated type begline, endline :: beginning or end of line anything :: any number of non-newlines something :: one or more non-newlines anyspace :: any amount of whitespace somespace :: one or more whitespace chars When you're done, you should use these 'Pattern' methods to do the searching: match() :: match at beginning of string search() :: find anywhere in string imatch() :: case-insensitive match isearch() :: case-insensitive search group(