ExpectPy support for regular expressions

The module will contain a variable, re_type, that will contain which support framework has been built: "re" for PCRE, "tclre" for Tcl regexp, and None for neither.


A PCRE object (re.compile) can be passed in a COMPILED clause to expect without modification. If the clause matches, then the object will contain a new attribute called "lastmatch" which will be the result of the obj.match call, equivalent to:
obj.lastmatch = obj.match(str_to_match)

The string passwd in a REGEXP clause will also be compiled implicitly into a PCRE object. The object is dereferenced before the expect method returns. Using groups when using REGEXP will gain nothing, use compiled objects instead.

ExpectPy.compile is the same method as re.compile. Refer to the re package in the Python library documentation.

Tcl regexp

Like the PCRE support, the expect method will either accept or implicitly build a TclRE object.

ExpectPy.compile is the same method as tclre.compile.


It is possible to build ExpectPy without regular expression support. Globbing, exact matching and null expressions are still supported within the expect method. An exception is raise (ExpectPy.error) if ExpectPy.REGEXP or ExpectPy.COMPILED are used.