in reply to Re^2: matching a regular expression
in thread matching a regular expression

Well said: just one more reason to use index instead of a regexp that fundamentally "emulates" index.

Replies are listed 'Best First'.
Re^4: matching a regular expression
by japhy (Canon) on May 18, 2006 at 16:13 UTC
    I know this is pedantic, but index() doesn't stop looking after it fails to find the target at position 0 of the string. The regex does. The regex fails very fast. Add a \Q...\E and an /i modifier, and you have a perfectly reasonable solution. And, as my solution above showed, you can get more bang for your buck.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      Gawd, I can trust you on the reputation of your expertise, but however pedantic you like to be... is that relevant in any way?!?

Re^4: matching a regular expression
by Jasper (Chaplain) on May 18, 2006 at 16:05 UTC
    Unless you wanted case insensitive indexing, which I'm not sure exists.

    You're being far too dismissive of the usefulness of a regex, I think.