Reputation: 899
Is it possible to split not just on one string but also a slice of strings? I.e.
strings.Split("Dogs and Cats are Great", "and"))
But instead of using one string, a slice of strings as so:
strings.Split("Dogs and Cats are Great", []string{"and", "are"}))
Upvotes: 3
Views: 163
Reputation: 109347
You can use a regular expression: http://play.golang.org/p/vCRCv4rt7s
re := regexp.MustCompile(`and|are`)
fmt.Printf("%q\n", re.Split("Dogs and Cats are Great", -1))
Upvotes: 5