Jump to content

Split a character string based on change of character: Difference between revisions

m
No edit summary
Line 1,209:
<lang>
local fn SplitString( inputStr as CFStringRef ) as CFStringRef
CFStringRef resultStr
NSUInteger i
 
if len( inputStr ) < 2 then resultStr = inputStr : exit fn
resultStr = left( inputStr, 1 )
for i = 2 to len( inputStr )
if fn StringIsEqual( mid( inputStr, i, 1 ) <>, mid( inputStr, i - 1, 1 ) ) == NO then resultStr = fn StringWithFormat( @"%@, ", resultStr )
resultStr = fn StringWithFormat( @"%@%@", resultStr, mid( inputStr, i, 1 ) )
next
i = len( resultStr ) - 2
resultStr = fn StringByReplacingCharactersInRange( resultStr, fn CFRangeMake( i, 1 ), @"" )
end fn = resultStr
 
Line 1,232:
g, HHH, 5, YY, ++, ///, \
</pre>
 
 
=={{header|Go}}==
729

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.