in reply to Re^2: Why would one want in a regex a class with only a single entry?
in thread Why would one want in a regex a class with only a single entry?

Given what I've been led to believe are the penalities of using classes, why wouldn't one check the variable to see if it has just one entry and cast it differently...i.e., in a more regex-engine-efficient form?
Because only in very unusual cases would the penalties amount to anything noticeable. And the extra code to treat one character specially means more opportunities for bugs as well as less readable/maintainable code.

In any case, the penalty is gone in 5.10.0 and will be gone in 5.8.9.

  • Comment on Re^3: Why would one want in a regex a class with only a single entry?

Replies are listed 'Best First'.
Re^4: Why would one want in a regex a class with only a single entry?
by ack (Deacon) on Mar 27, 2008 at 05:53 UTC

    Good point. I suspected that was probably the case.

    Thanks, ysth.

    ack Albuquerque, NM