~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/strings/strings.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
        return a[0 : na+1]
199
199
}
200
200
 
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) }
209
209
 
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)
219
219
}
220
220
 
 
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) }
 
226
 
 
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)
 
233
}
 
234
 
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 {