Regular expressions vs find?
Aahz Maruch
aahz at netcom.com
Mon Jun 19 09:23:34 EDT 2000
In article <20000619184000.639516 at 210.9.22.17>,
Matthew Schinckel <matt at null.net> wrote:
>"William Dandreta" <wjdandreta at worldnet.att.net> wrote:
>>
>> I recently read a message that suggested that using regular
>> expressions might be faster than the find function. I've heard the
>> term regular expression used from time to time but I don't know what
>> it means. Could someone give me a simple explanation?
>
>I have come across one example where re was much faster than using
>string.find: I was stripping out html tags, and doing a one line
>re.sub('<*?>','') was much faster than using string.find() and slice
>notation.
Sure! But then you're not really doing just a string.find(). The point
is that for any operation where string.find() alone can be used, it will
be faster than an re. Any time you add complexity, such as find/replace
with a pattern rather than a fixed string, chances are good that the re
will be faster.
--
--- Aahz (Copyright 2000 by aahz at netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"The only problem with Microsoft is they just have no taste." --Steve Jobs
(From _Triumph of the Nerds_ PBS special)
More information about the Python-list
mailing list