Optimisation of regexps in Perl?

F

Fredrik Ramsberg

When searching for a specific sequence of charcters, like ($text =~ /monkeybreath/),
how efficient is Perl compared to other algorithms specifically developed for this
purpose? Does Perl recognise that it can use its index() functionality to search?

And how efficient are index() and rindex() compared to the best text search
algorithms?

Regards,

/Fredrik
 
G

Gunnar Hjalmarsson

Fredrik said:
When searching for a specific sequence of charcters, like ($text =~
/monkeybreath/), how efficient is Perl compared to other algorithms
specifically developed for this purpose? Does Perl recognise that
it can use its index() functionality to search?

And how efficient are index() and rindex() compared to the best
text search algorithms?

Have you checked out the Benchmark module?
 
F

Fredrik Ramsberg

Gunnar Hjalmarsson said:
Have you checked out the Benchmark module?

I haven't heard of it before. Will check it out. Thanks!

I've found an answer in a book though - Mastering Regular Expressions
by Jeffrey Friedl.
It says most regexp engines use the Boyer-Moore algorithm if there's a
fixed substring
they need to find as part of a regexp. As far as I know, Boyer-Moore
is as fast as they
come.

/Fredrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top