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/2b8c9ec4-7967-46d3-b6d7-29730eb0f6c3n%40googlegroups.com.

Reply via email to