in reply to Re: Search and Replace.
in thread Search and Replace.

Don't replace spaces with \s. \s would be slower since it matches spaces, tabs, carriage returns (I think) and line feeds, and even more if it's a unicode string. "\x20", "\040", "\", and "[ ]" work. (I wonder if the last is slower than the others. I'll Benchmark later.)

You've also added useless captures. Don't use (...) (which incures a speed penalty), use (?:...).