212
212
return a[0 : na+1]
215
// Split slices s into subslices separated by sep and returns a slice of
215
// SplitN slices s into subslices separated by sep and returns a slice of
216
216
// the subslices between those separators.
217
// If sep is empty, Split splits after each UTF-8 sequence.
217
// If sep is empty, SplitN splits after each UTF-8 sequence.
218
218
// The count determines the number of subslices to return:
219
219
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
220
220
// n == 0: the result is nil (zero subslices)
221
221
// n < 0: all subslices
222
func Split(s, sep []byte, n int) [][]byte { return genSplit(s, sep, 0, n) }
222
func SplitN(s, sep []byte, n int) [][]byte { return genSplit(s, sep, 0, n) }
224
// SplitAfter slices s into subslices after each instance of sep and
224
// SplitAfterN slices s into subslices after each instance of sep and
225
225
// returns a slice of those subslices.
226
// If sep is empty, Split splits after each UTF-8 sequence.
226
// If sep is empty, SplitAfterN splits after each UTF-8 sequence.
227
227
// The count determines the number of subslices to return:
228
228
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
229
229
// n == 0: the result is nil (zero subslices)
230
230
// n < 0: all subslices
231
func SplitAfter(s, sep []byte, n int) [][]byte {
231
func SplitAfterN(s, sep []byte, n int) [][]byte {
232
232
return genSplit(s, sep, len(sep), n)
235
// Split slices s into all subslices separated by sep and returns a slice of
236
// the subslices between those separators.
237
// If sep is empty, Split splits after each UTF-8 sequence.
238
// It is equivalent to SplitN with a count of -1.
239
func Split(s, sep []byte) [][]byte { return genSplit(s, sep, 0, -1) }
241
// SplitAfter slices s into all subslices after each instance of sep and
242
// returns a slice of those subslices.
243
// If sep is empty, SplitAfter splits after each UTF-8 sequence.
244
// It is equivalent to SplitAfterN with a count of -1.
245
func SplitAfter(s, sep []byte) [][]byte {
246
return genSplit(s, sep, len(sep), -1)
235
249
// Fields splits the array s around each instance of one or more consecutive white space
236
250
// characters, returning a slice of subarrays of s or an empty list if s contains only white space.
237
251
func Fields(s []byte) [][]byte {