You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
res += thisString.substring(prev, thisString.size)
222
-
223
-
valinitialResult= res.result()
224
-
pos = initialResult.length
225
-
while (pos >0&& initialResult(pos -1).isEmpty) pos = pos -1
226
-
if (pos != initialResult.length) {
227
-
valtrimmed=newArray[String](pos)
228
-
Array.copy(initialResult, 0, trimmed, 0, pos)
229
-
trimmed
230
-
} else initialResult
231
-
} elseArray[String](thisString)
232
-
}
204
+
privatedefescape(ch: Char):String=if (
205
+
(ch >='a') && (ch <='z') ||
206
+
(ch >='A') && (ch <='Z') ||
207
+
(ch >='0'&& ch <='9')) ch.toString
208
+
else"\\"+ ch
209
+
210
+
/** Split this string around the separator character
211
+
*
212
+
* If this string is the empty string, returns an array of strings
213
+
* that contains a single empty string.
214
+
*
215
+
* If this string is not the empty string, returns an array containing
216
+
* the substrings terminated by the start of the string, the end of the
217
+
* string or the separator character, excluding empty trailing substrings
218
+
*
219
+
* If the separator character is a surrogate character, only split on
220
+
* matching surrogate characters if they are not part of a surrogate pair
221
+
*
222
+
* The behaviour follows, and is implemented in terms of <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split%28java.lang.String%29">String.split(re: String)</a>
223
+
*
224
+
*
225
+
* @example {{{
226
+
* "a.b".split('.') //returns Array("a", "b")
227
+
*
228
+
* //splitting the empty string always returns the array with a single
229
+
* //empty string
230
+
* "".split('.') //returns Array("")
231
+
*
232
+
* //only trailing empty substrings are removed
233
+
* "a.".split('.') //returns Array("a")
234
+
* ".a.".split('.') //returns Array("", "a")
235
+
* "..a..".split('.') //returns Array("", "", "a")
236
+
*
237
+
* //all parts are empty and trailing
238
+
* ".".split('.') //returns Array()
239
+
* "..".split('.') //returns Array()
240
+
*
241
+
* //surrogate pairs
242
+
* val high = 0xD852.toChar
243
+
* val low = 0xDF62.toChar
244
+
* val highstring = high.toString
245
+
* val lowstring = low.toString
246
+
*
247
+
* //well-formed surrogate pairs are not split
248
+
* val highlow = highstring + lowstring
249
+
* highlow.split(high) //returns Array(highlow)
250
+
*
251
+
* //bare surrogate characters are split
252
+
* val bare = "_" + highstring + "_"
253
+
* bare.split(high) //returns Array("_", "_")
254
+
*
255
+
* }}}
256
+
*
257
+
* @paramseparator the character used as a delimiter
0 commit comments