in reply to Re: Re: Removing backtracking from a .*? regexp
in thread Removing backtracking from a .*? regexp

Cool beans if so! Sounds like a good candidate for a Meditation.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"
  • Comment on Re: Re: Re: Removing backtracking from a .*? regexp

Replies are listed 'Best First'.
Re: Re: Re: Re: Removing backtracking from a .*? regexp
by BrowserUk (Patriarch) on Nov 17, 2003 at 21:30 UTC

    No meditation necessary.

    print 'Found it' if $s =~ /$thing/; print 'Found it' if 1+index( $s, $thing );

    Both work. The latter is marginally quicker under most circumstances, but as you can see it is notationally more complex.

    If you find the additional complexity intimidating, or don't need the (very) marginal additional performance, stick with the former.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!
    Wanted!