Hi Peter, I don't think this is the solution: https://go.dev/play/p/Ti7UEGd1BVE . I think "All" means that it can deal with several copies of the regexp, rather than returning all matches of the group.
All the best, Jochen On Friday, 10 February 2023 at 16:09:04 UTC Peter Galbavy wrote: > 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/de25ad20-02bc-4fb6-ab3c-4adc30702c74n%40googlegroups.com.