198
198
return a[0 : na+1]
201
// Split slices s into substrings separated by sep and returns a slice of
201
// SplitN slices s into substrings separated by sep and returns a slice of
202
202
// the substrings between those separators.
203
// If sep is empty, Split splits after each UTF-8 sequence.
203
// If sep is empty, SplitN splits after each UTF-8 sequence.
204
204
// The count determines the number of substrings to return:
205
205
// n > 0: at most n substrings; the last substring will be the unsplit remainder.
206
206
// n == 0: the result is nil (zero substrings)
207
207
// n < 0: all substrings
208
func Split(s, sep string, n int) []string { return genSplit(s, sep, 0, n) }
208
func SplitN(s, sep string, n int) []string { return genSplit(s, sep, 0, n) }
210
// SplitAfter slices s into substrings after each instance of sep and
210
// SplitAfterN slices s into substrings after each instance of sep and
211
211
// returns a slice of those substrings.
212
// If sep is empty, Split splits after each UTF-8 sequence.
212
// If sep is empty, SplitAfterN splits after each UTF-8 sequence.
213
213
// The count determines the number of substrings to return:
214
214
// n > 0: at most n substrings; the last substring will be the unsplit remainder.
215
215
// n == 0: the result is nil (zero substrings)
216
216
// n < 0: all substrings
217
func SplitAfter(s, sep string, n int) []string {
217
func SplitAfterN(s, sep string, n int) []string {
218
218
return genSplit(s, sep, len(sep), n)
221
// Split slices s into all substrings separated by sep and returns a slice of
222
// the substrings between those separators.
223
// If sep is empty, Split splits after each UTF-8 sequence.
224
// It is equivalent to SplitN with a count of -1.
225
func Split(s, sep string) []string { return genSplit(s, sep, 0, -1) }
227
// SplitAfter slices s into all substrings after each instance of sep and
228
// returns a slice of those substrings.
229
// If sep is empty, SplitAfter splits after each UTF-8 sequence.
230
// It is equivalent to SplitAfterN with a count of -1.
231
func SplitAfter(s, sep string) []string {
232
return genSplit(s, sep, len(sep), -1)
221
235
// Fields splits the string s around each instance of one or more consecutive white space
222
236
// characters, returning an array of substrings of s or an empty list if s contains only white space.
223
237
func Fields(s string) []string {