FindAllStringSubmatch() ? https://pkg.go.dev/regexp#Regexp.FindAllStringSubmatch
On Friday, 10 February 2023 at 12:52:34 UTC Jochen Voss wrote: > Dear all, > > What happens if a group in a regular expression matches repeatedly, via > the * operator? Experimentally I found that FindStringSubmatch then > returns the text of the last match. Is this guaranteed somewhere (I didn't > find anything about this on https://pkg.go.dev/regexp )? Also, is there > an easy way to get the other matched strings? > > Example: https://go.dev/play/p/h5UDongaz7u > > regexp: `A\s*(?:([a-z]+)\s*)*B` > applied to: "one A two three four B five" > the inner group gives me "four" > > Is FindStringSubmatch guaranteed to return the "four"? > Is there a way to also get the matched "two" and "three"? > > Many thanks, > Jochen > > -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9fd6b4b1-cb33-4a75-9bdf-54c25649fe19n%40googlegroups.com.