matching multiple regexs to a single line...
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Nov 19 21:17:02 EST 2002
>>>>> "Alexander" == Alexander Sendzimir <lists at battleface.com> writes:
Alexander> Why re and no sre?
As I understand it, sre is an update to the regex engine of 1.5.2.
The module re.py is a compatibility wrapper which imports sre. From
python 2.2.2's re.py:
engine = "sre"
# engine = "pre"
if engine == "sre":
# New unicode-aware engine
from sre import *
from sre import __all__
else:
# Old 1.5.2 engine. This one supports 8-bit strings only,
# and will be removed in 2.0 final.
from pre import *
from pre import __all__
So there is nothing wrong with importing sre, but import re does the
same thing on any reasonably modern system and is (AFAIK) The Way
To Do It <wink>.
>From the Library Reference:
*Implementation note:* The `re' module has two distinct
implementations: `sre' is the default implementation and includes
Unicode support, but may run into stack limitations for some
patterns. Though this will be fixed for a future release of
Python, the older implementation (without Unicode support) is
still available as the `pre' module.
John Hunter
More information about the Python-list
mailing list