[a:b] gives you the elements from a to b-1 inclusive. So if you want the pair at position x, it has to be [x:x+2]
https://go.dev/play/p/3nvEfOjdfnj On Thursday 14 December 2023 at 08:38:57 UTC Peter Galbavy wrote: > I noticed today that the regexp docs read: > > If 'Index' is present, matches and submatches are identified by byte index > pairs within the input string: result[2*n:2*n+2] identifies the indexes of > the nth submatch. > > I think that should be result[2*n:2*n+1] - at least in my code that's how > it is working. > > If I'm right, happy to raise a doc bug, but never done that, so not sure > how - for a one digit change? > > Peter > -- 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/415721e0-ddff-4b35-9490-79be363f7215n%40googlegroups.com.