Split a character string based on change of character: Difference between revisions
Content deleted Content added
No edit summary |
added Tcl |
||
Line 540:
g, HHH, 5, YY, ++, ///, \
</pre>
=={{header|Tcl}}==
This is most concise with regular expressions. Note well the two steps: it could be achieved in one very clever regexp, but being that clever is usually a bad idea (for both readability and performance, in this case).
<lang Tcl>set string "gHHH5YY++///\\"
regsub -all {(.)\1*} $string {\0, } string
regsub {, $} $string {} string
puts $string</lang>
=={{header|zkl}}==
|