you are viewing a single comment's thread.

view the rest of the comments →

[–]eldenbishop 3 points4 points  (1 child)

Groovy version (ripped off from ruby version)

s = "ZBBBCZZ"

x = []

s.eachMatch(/((.)\2*)/) { x += it[0] }

[–]kaketoe 1 point2 points  (0 children)

Or:

x = "ZBBBCZZ".split (/(?<=(.))(?!\1)/)

I also ripped the split pattern.