diff options
author | Guido van Rossum <guido@python.org> | 2000-03-31 14:58:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-31 14:58:54 (GMT) |
commit | 7627c0de6968471996ce05aab200115d56efa1d5 (patch) | |
tree | 9c4191aa38d9b7428d11c1b6267b95e5add41afa /Lib/sre.py | |
parent | 7a5b796322e2bf58fa8afe78bbaccfcc9492d178 (diff) | |
download | cpython-7627c0de6968471996ce05aab200115d56efa1d5.zip cpython-7627c0de6968471996ce05aab200115d56efa1d5.tar.gz cpython-7627c0de6968471996ce05aab200115d56efa1d5.tar.bz2 |
Added Fredrik Lundh's sre module and its supporting cast.
NOTE: THIS IS VERY ROUGH ALPHA CODE!
Diffstat (limited to 'Lib/sre.py')
-rw-r--r-- | Lib/sre.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/sre.py b/Lib/sre.py new file mode 100644 index 0000000..0b41057 --- /dev/null +++ b/Lib/sre.py @@ -0,0 +1,46 @@ +# -*- Mode: Python; tab-width: 4 -*- +# +# Secret Labs' Regular Expression Engine +# $Id$ +# +# re-compatible interface for the sre matching engine +# +# Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. +# +# This code can only be used for 1.6 alpha testing. All other use +# require explicit permission from Secret Labs AB. +# +# Portions of this engine have been developed in cooperation with +# CNRI. Hewlett-Packard provided funding for 1.6 integration and +# other compatibility work. +# + +""" +this is a long string +""" + +import sre_compile + +# -------------------------------------------------------------------- +# public interface + +def compile(pattern, flags=0): + return sre_compile.compile(pattern, _fixflags(flags)) + +def match(pattern, string, flags=0): + return compile(pattern, _fixflags(flags)).match(string) + +def search(pattern, string, flags=0): + assert flags == 0 + return compile(pattern, _fixflags(flags)).search(string) + +# FIXME: etc + +# -------------------------------------------------------------------- +# helpers + +def _fixflags(flags): + # convert flag bitmask to sequence + assert flags == 0 + return () + |