Package nltk :: Module sourcedstring :: Class SourcedStringRegexp
[hide private]
[frames] | no frames]

type SourcedStringRegexp

source code

object --+
         |
        SourcedStringRegexp

Wrapper for regexp pattern objects that cause the sub and subn methods to return sourced strings.

Instance Methods [hide private]
 
__init__(self, pattern, flags=0) source code
 
__getattr__(self, attr) source code
 
subn(self, repl, string, count=0) source code
 
sub(self, repl, string, count=0) source code
Static Methods [hide private]
 
patch_re_module()
Modify the standard re module by installing new versions of the functions re.compile, re.sub, and re.subn, causing regular expression substitutions to return SourcedStrings when called with SourcedStrings arguments.
source code
 
unpatch_re_module()
Restore the standard re module to its original state (undoing the work that was done by patch_re_module()).
source code
Method Details [hide private]

__init__(self, pattern, flags=0)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

patch_re_module()
Static Method

source code 

Modify the standard re module by installing new versions of the functions re.compile, re.sub, and re.subn, causing regular expression substitutions to return SourcedStrings when called with SourcedStrings arguments.

Use this function only if necessary: it potentially affects all Python modules that use regular expressions!