]> code.delx.au - monosys/commitdiff
Hacky perl-like regexp wrapper
authorJames Bunton <jamesbunton@fastmail.fm>
Wed, 3 Oct 2007 23:32:20 +0000 (09:32 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Wed, 3 Oct 2007 23:32:20 +0000 (09:32 +1000)
python/quickre.py [new file with mode: 0644]

diff --git a/python/quickre.py b/python/quickre.py
new file mode 100644 (file)
index 0000000..a1b0b80
--- /dev/null
@@ -0,0 +1,17 @@
+# Copyright 2007 James Bunton <jamesbunton@fastmail.fm>
+# Licensed for distribution under the GPL version 2, check COPYING for details
+# Quicker, easier regular expressions
+
+import re
+
+class RE(object):
+       def __init__(self, regex):
+               self.regex = re.compile(regex)
+       
+       def __eq__(self, s):
+               assert isinstance(s, basestring)
+               return self.regex.search(s)
+       
+       def __ne__(self, s):
+               return not self == s
+