FAQ
Another take using bufio.Scanner <http://golang.org/pkg/bufio/#Scanner>:
https://play.golang.org/p/gZFodmTXtS

Peter
On Fri, Jan 9, 2015 at 5:33 AM, C Banning wrote:

http://play.golang.org/p/PTqUFl2cjE

On Thursday, January 8, 2015 at 6:16:44 AM UTC-6, [email protected]
wrote:
I have a string "hello <format> world" and I need to split it based on
multiple characters "<> ". How do I get this ?

One option is:

strings.FieldsFunc("hello <format> world", func (r rune) bool {

return r == '<' || r == '>'
})


But this gives ["hello","format","world"].

Is there a way to retain even the delimiters also in this list?

--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 12 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 8, '15 at 2:35p
activeJan 9, '15 at 1:33p
posts12
users9
websitegolang.org

People

Translate

site design / logo © 2023 Grokbase