If we run this example with go 1.16
re := regexp.MustCompile(`(?:^|_)(.)`)
fmt.Printf("%s", re.FindAll([]byte("i_love_golang_and_json_so_much"), -1))
the output is:
[i _l _g _a _j _s _m]
However, if we run it in Python3.6
import re
print(re.findall('(?:^|_)(.)', 'i_love_golang_and_json_so_much'))
the output is:
['i', 'l', 'g', 'a', 'j', 's', 'm']
The output of go has a leading _ before each match group.
Since ?: is for non capturing group, it seems the result from Python is more reasonable?
Why the result from go carries a leading _?
Is there a way to get the same output as Python(without leading _) with go?