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. Advertising

  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. Advertising

  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. Advertising

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. Roedy Green

    boolean loop optimisation

    Roedy Green, Sep 11, 2003, in forum: Java
    Replies:
    8
    Views:
    2,811
    Chris Uppal
    Sep 12, 2003
  2. sorry.no.email@post_NG.com

    Search Engine Optimisation

    sorry.no.email@post_NG.com, May 8, 2006, in forum: HTML
    Replies:
    0
    Views:
    342
    sorry.no.email@post_NG.com
    May 8, 2006
  3. Tammo Tjarks
    Replies:
    3
    Views:
    104
    Wolfgang Nádasi-Donner
    Sep 9, 2007
  4. Brendan Byrd/SineSwiper

    Removing Perl comments and strings using regexps

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

Share This Page