groupBy package:text

O(n) Group characters in a string according to a predicate.
The groupBy function is the non-overloaded version of group.