]> code.delx.au - monosys/blob - python/quickre.py
Virgin mobile credit checking
[monosys] / python / quickre.py
1 # Copyright 2007 James Bunton <jamesbunton@fastmail.fm>
2 # Licensed for distribution under the GPL version 2, check COPYING for details
3 # Quicker, easier regular expressions
4
5 import re
6
7 class RE(object):
8 def __init__(self, regex):
9 self.regex = re.compile(regex)
10
11 def __eq__(self, s):
12 assert isinstance(s, basestring)
13 return self.regex.search(s)
14
15 def __ne__(self, s):
16 return not self == s
17