Optimisation of regexps in Perl?

Discussion in 'Perl' started by Fredrik Ramsberg, Oct 14, 2003.

  1. 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
     
    Fredrik Ramsberg, Oct 14, 2003
    #1
    1. Advertisements

  2. Fredrik Ramsberg wrote:
    > 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?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Oct 15, 2003
    #2
    1. Advertisements

  3. Gunnar Hjalmarsson <> wrote in message news:<_w0jb.29228$>...
    > Fredrik Ramsberg wrote:
    > > 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?


    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
     
    Fredrik Ramsberg, Oct 15, 2003
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    781
  2. Spartanicus

    Help with Regexps wanted

    Spartanicus, Oct 21, 2004, in forum: HTML
    Replies:
    4
    Views:
    621
    William Park
    Oct 25, 2004
  3. Klaus Alexander Seistrup

    Expanding regexps

    Klaus Alexander Seistrup, Oct 28, 2003, in forum: Python
    Replies:
    5
    Views:
    512
    Klaus Alexander Seistrup
    Oct 29, 2003
  4. Kirk Strauser

    Problems with regexps

    Kirk Strauser, Nov 7, 2003, in forum: Python
    Replies:
    6
    Views:
    417
    Edward K. Ream
    Nov 8, 2003
  5. Magnus Lie Hetland

    Recursive regexps?

    Magnus Lie Hetland, Nov 19, 2004, in forum: Python
    Replies:
    4
    Views:
    805
    Jeremy Bowers
    Nov 20, 2004
  6. Tammo Tjarks
    Replies:
    3
    Views:
    229
    Wolfgang Nádasi-Donner
    Sep 9, 2007
  7. Brendan Byrd/SineSwiper

    Removing Perl comments and strings using regexps

    Brendan Byrd/SineSwiper, Jul 17, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    274
    Brendan Byrd/SineSwiper
    Jul 18, 2003
  8. R Krause
    Replies:
    12
    Views:
    301
    Ben Morrow
    Nov 22, 2006
Loading...