Regular expressions vs find?

Matthew Schinckel matt at null.net
Mon Jun 19 20:39:50 EDT 2000


"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?
> 
> Bill

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.

Try both, use the profiler, and compare. (I'll guess someone else will
give an explanation about them).

Matt.



More information about the Python-list mailing list