Split a character string based on change of character: Difference between revisions
Content added Content deleted
m (→{{header|Go}}: User new and more efficient strings.Builder) |
No edit summary |
||
Line 835: | Line 835: | ||
return s |
return s |
||
end</lang> |
end</lang> |
||
=={{header|Maple}}== |
|||
Added an additional backlash to escape the \ character at the end. |
|||
<lang Maple>splitChange := proc(str::string) |
|||
local start,i,len; |
|||
start := 1; |
|||
len := StringTools:-Length(str); |
|||
for i from 2 to len do |
|||
if str[i] <> str[start] then |
|||
printf("%s, ", str[start..i-1]); |
|||
start := i: |
|||
end if; |
|||
end do; |
|||
printf("%s", str[start..len]); |
|||
end proc; |
|||
splitChange("gHHH5YY++///\\");</lang> |
|||
{{out}} |
|||
<pre>g, HHH, 5, YY, ++, ///, \</pre> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |