in reply to Re: whitespace eliminator for arrays
in thread whitespace eliminator for arrays

Out of curiosity, why would specifiying the hex for each type of whitespace and using tr be better than a s///? Also, how does putting the for after the statement increase efficiency? Not that I'm nagging, I'm curious.
  • Comment on Re: Re: whitespace eliminator for arrays

Replies are listed 'Best First'.
Re^3: whitespace eliminator for arrays
by Aristotle (Chancellor) on Oct 22, 2002 at 19:36 UTC

    You missed the little + I added to the regex. :-) Using for as expression modificator wasn't the point. The + will cause the regex to delete sequences of whitespace in one fell swoop, rather than character by character.

    tr is better in that it doesn't fire up the entire regex engine to do its job. It's therefor more efficient for the specific job of deleting all of a list of characters from a string. However, it doesn't understand classes like \s as the regex engine does, so you have to spell out all the characters. Doing so with hex codes is merely one choice out of several.

    Makeshifts last the longest.

      I see. Thanks for the reply.