class documentation

class Re(object): (source)

View In Hierarchy

Wrapper around regex pattern objects which memorizes the last match object and gives list access to it's capturing groups. See module re for regex docs.

Usage:

        my_re = Re('^(\w[\w\+\-\.]+)\?(.*)')

        if my_re.match(string):
                print my_re[1], my_re[2]
Method __getitem__ Undocumented
Method __init__ Constructor takes same arguments as re.compile()
Method __len__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method end No summary
Method match Same as re.match()
Method search Same as re.search()
Method start No summary
Method sublist No summary
Class Variable __slots__ Undocumented
Instance Variable m Undocumented
Instance Variable p Undocumented
Instance Variable r Undocumented
def __getitem__(self, i): (source)

Undocumented

def __init__(self, pattern, flags=0): (source)
Constructor takes same arguments as re.compile()
def __len__(self): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def end(self, group=0): (source)
Return the indices of the end of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return -1 if group exists but did not contribute to the match. See re.matchobject for details
def match(self, string): (source)
Same as re.match()
def search(self, string): (source)
Same as re.search()
def start(self, group=0): (source)
Return the indices of the start of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return -1 if group exists but did not contribute to the match. See re.matchobject for details
def sublist(self, repl, list): (source)
This method is similar to "sub()" in that it substitutes regex matches with the result of calling the argument "repl" with the Re object as argument. The difference is that this function takes a list as argument and executes the substitution for all strings in the list while ignoring any non-string items. Also it does not substitute the results in the string, but expands to a list where each part is either a piece of the original string or the result of calling "repl". This method is useful to build a tokenizer. The method "repl" can return token objects and the resulting list of strings and tokens can be fed through this method several times for different regexes.
__slots__: tuple[str, ...] = (source)

Undocumented

Undocumented

Undocumented

Undocumented