http://qs1969.pair.com?node_id=1176235


in reply to Faster regex to split a string into runs of similar characters?

If you want to match all 256 byte values, you'll need the /s modifier. I thought this would just be more correct, but it also happen to be slightly faster (4% on my computer), certainly because it's faster to match anything rather than check that the character is different from "\n".

Beside that, why are you using look-ahead assertions? Isn't /((.)\2+)/g stricly identical to your regex? I don't see a performance difference with that though, so maybe perl optimizes away the look-ahead.