> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/split_a_character_string_based_on_change_of_character.md).

# Split a character string based on change of character

```ruby
func group(str) {
    gather {
        while (var match = (str =~ /((.)\g{-1}*)/g)) {
            take(match[0])
        }
    }
}
 
say group(ARGV[0] \\ 'gHHH5YY++///\\').join(', ')
```

#### Output:

```
g, HHH, 5, YY, ++, ///, \
```
