regexp question
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 pkg.go.dev/regexp )? Also, is there an easy way to get the other matched strings?
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
Read more here: Source link