Guido van Rossum | 7627c0d | 2000-03-31 14:58:54 +0000 | [diff] [blame] | 1 | # -*- Mode: Python; tab-width: 4 -*- |
| 2 | # |
| 3 | # Secret Labs' Regular Expression Engine |
| 4 | # $Id$ |
| 5 | # |
| 6 | # re-compatible interface for the sre matching engine |
| 7 | # |
| 8 | # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. |
| 9 | # |
| 10 | # This code can only be used for 1.6 alpha testing. All other use |
| 11 | # require explicit permission from Secret Labs AB. |
| 12 | # |
| 13 | # Portions of this engine have been developed in cooperation with |
| 14 | # CNRI. Hewlett-Packard provided funding for 1.6 integration and |
| 15 | # other compatibility work. |
| 16 | # |
| 17 | |
| 18 | """ |
| 19 | this is a long string |
| 20 | """ |
| 21 | |
| 22 | import sre_compile |
| 23 | |
| 24 | # -------------------------------------------------------------------- |
| 25 | # public interface |
| 26 | |
| 27 | def compile(pattern, flags=0): |
| 28 | return sre_compile.compile(pattern, _fixflags(flags)) |
| 29 | |
| 30 | def match(pattern, string, flags=0): |
| 31 | return compile(pattern, _fixflags(flags)).match(string) |
| 32 | |
| 33 | def search(pattern, string, flags=0): |
Guido van Rossum | 7627c0d | 2000-03-31 14:58:54 +0000 | [diff] [blame] | 34 | return compile(pattern, _fixflags(flags)).search(string) |
| 35 | |
| 36 | # FIXME: etc |
| 37 | |
| 38 | # -------------------------------------------------------------------- |
| 39 | # helpers |
| 40 | |
| 41 | def _fixflags(flags): |
| 42 | # convert flag bitmask to sequence |
Guido van Rossum | 1b6aecb | 2000-05-02 15:52:33 +0000 | [diff] [blame] | 43 | assert not flags |
Guido van Rossum | 7627c0d | 2000-03-31 14:58:54 +0000 | [diff] [blame] | 44 | return () |
| 45 | |