def __rlshift__(self, count):
self.count = count ; return self
-class Match(str):
+class Match:
""" A Match is actually a mix of a Python Pattern and MatchObject """
def __init__(self, pattern = None, flags = None):
""" flags is a string: 'i' for case-insensitive etc.; it is just
def __call__(self, pattern, flags = None):
assert isinstance(pattern, str) or pattern is None
assert isinstance(flags, str) or flags is None
- str.__init__(self, pattern)
self.replaced = 0 # set by subn() inside MatchReplace
self.found = None # set by search() to a MatchObject
self.pattern = pattern
else:
self.regex = re.compile(self.pattern)
return self
+ def __repr__(self):
+ return self.pattern
def __truth__(self):
return self.found is not None
def __and__(self, string):