TclRE - Tcl based regular expression module

This module was created as a substitution for PCRE support if there are conflicts with the Tcl library (See known bugs).

compile method

tclre.compile(pattern)
This function returns a Tclregexp object, compiled with the given pattern.

Tclregexp objects

__len__
the number of "slots" available for grouping
__getitem__
return the string matched in the given group
__getslice__
return a list of strings matched
match
method to match against a given string
group
method to return a tuple of start and stop positions for a specified group; this is relative to the input buffer.
pattern
the string used to compile the regular expression

Examples

Read and print from some pipe object.
line_re = tclre.compile('([a-zA-Z_0-9]+)[ \t]+(.*)\n')
matched = line_re.match(pipe.readline())
print line_re[1] # print the first word