in reply to Re: Get a known substring from a string
in thread Get a known substring from a string
That is equivalent to $found = 'thispart' if 1+index( $str, 'thispart' );, but index is 3 times faster:
s='the quick brown fox jumps over the lazy dog'; cmpthese -1,{ a => q[ if( $s =~ m[(lazy)] ){ $found=$1 } ], b => q[ $found = 'lazy' if 1+index( $s, 'lazy' ); ], };; Rate a b a 585631/s -- -77% b 2535746/s 333% --
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Get a known substring from a string
by Corion (Patriarch) on Sep 10, 2016 at 09:42 UTC | |
by BrowserUk (Patriarch) on Sep 10, 2016 at 11:40 UTC | |
by flowdy (Scribe) on Sep 13, 2016 at 07:34 UTC | |
by BrowserUk (Patriarch) on Sep 13, 2016 at 12:05 UTC | |
by flowdy (Scribe) on Sep 14, 2016 at 19:03 UTC | |
| |
by Anonymous Monk on Sep 13, 2016 at 09:16 UTC |
In Section
Seekers of Perl Wisdom