Anonymous user
Split a character string based on change of character: Difference between revisions
Split a character string based on change of character (view source)
Revision as of 09:40, 5 February 2017
, 7 years agoadded Tcl
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}}==
|