Closed hikari-no-yume closed 10 years ago
Fix it, fix it, fix it! :)
On 25 Aug, 2014, at 11:55 pm, Andrea Faulds notifications@github.com wrote:
C'mon, strings gotta have one. Either split or explode, I'd go with the former as it's a more common name in other languages, and it's the verb the manual uses to describe what explode does.
I'd suggest this signature (pseudo-code):
UString::split(UString $delimeter, ?int $limit = NULL): Array
The optional $limit parameter is a number. If specified, then the string is only split $limit times. This is really useful. Examples:
(new UString("1,2,3,4"))->split(new UString(",")); // => ["1", "2", "3", "4"]
(new UString("1,2,3,4"))->split(new UString(","), 1); // => ["1", "2,3,4"]
(new UString("1,2,3,4"))->split(new UString(","), 2); // => ["1", "2", "3,4"]
(new UString(",1,2,,3,4,"))->split(new UString(",")); // => ["", "1", "2", "", "3", "4", ""] — Reply to this email directly or view it on GitHub.
+1
Nicely done, thanks :)
What was the ::pad() bug?
On 26 Aug, 2014, at 3:14 am, Andrea Faulds notifications@github.com wrote:
Done: 3b72ddd
— Reply to this email directly or view it on GitHub.
@datibbaw When a string
was passed, you used the size in bytes as the length. I fixed it to take the length of the resulting UnicodeString
.
C'mon, strings gotta have one. Either
split
orexplode
, I'd go with the former as it's a more common name in other languages, and it's the verb the manual uses to describe whatexplode
does.I'd suggest this signature (pseudo-code):
The optional
$limit
parameter is a number. If specified, then the string is only split$limit
times. This is a really useful feature.Examples:
One way to implement it (in Game Maker Language, it's C-like but strings indexed from 1): https://github.com/Medo42/Gang-Garrison-2/blob/master/Source/gg2/Scripts/split.gml