Copyright (C) 2000-2012 |
GNU Info (python2.1-lib.info)Regular Expression ObjectsRegular Expression Objects -------------------------- Compiled regular expression objects support the following methods and attributes: `search(string[, pos[, endpos]])' Scan through STRING looking for a location where this regular expression produces a match, and return a corresponding `MatchObject' instance. Return `None' if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string. The optional POS and ENDPOS parameters have the same meaning as for the `match()' method. `match(string[, pos[, endpos]])' If zero or more characters at the beginning of STRING match this regular expression, return a corresponding `MatchObject' instance. Return `None' if the string does not match the pattern; note that this is different from a zero-length match. *Note:* If you want to locate a match anywhere in STRING, use `search()' instead. The optional second parameter POS gives an index in the string where the search is to start; it defaults to `0'. This is not completely equivalent to slicing the string; the `'^'' pattern character matches at the real beginning of the string and at positions just after a newline, but not necessarily at the index where the search is to start. The optional parameter ENDPOS limits how far the string will be searched; it will be as if the string is ENDPOS characters long, so only the characters from POS to ENDPOS will be searched for a match. `split(string[, maxsplit` = 0'])' Identical to the `split()' function, using the compiled pattern. `findall(string)' Identical to the `findall()' function, using the compiled pattern. `sub(repl, string[, count` = 0'])' Identical to the `sub()' function, using the compiled pattern. `subn(repl, string[, count` = 0'])' Identical to the `subn()' function, using the compiled pattern. `flags' The flags argument used when the RE object was compiled, or `0' if no flags were provided. `groupindex' A dictionary mapping any symbolic group names defined by "(?P<ID>)" to group numbers. The dictionary is empty if no symbolic groups were used in the pattern. `pattern' The pattern string from which the RE object was compiled. automatically generated by info2www version 1.2.2.9 |