Next / Previous / Contents / TCC Help System / NM Tech homepage

28.5.3. Compiled regular expression objects

Compiled regular expression objects returned by re.compile() have these methods:

.match(s[,[ps][,pe]])

If the start of string s matches, return a MatchObject; if there is no match, return None. If ps is given, it specifies the index within s where matching is to start; this defaults to 0. If pe is given, it specifies the maximum length of s that can be used in matching.

.pattern

The string from which this object was compiled.

.search(s[,[ps][,pe]])

Like match(), but matches anywhere in s.

.split(s[,maxsplit=m])

Like re.split().

.sub(R,s[,count=c])

Like re.sub().