```
func Test_1(t *testing.T){
var re = regexp.MustCompile(`(?<!-)\d`)
content:=`-1,1,2,-2,3,4`
for _,match:=range re.FindAllString(content,-1){
println(match)
}
}
```
报错
panic: regexp: Compile(`(?<!-)\d`): error parsing regexp: invalid or unsupported Perl syntax: `(?<`
目前查到原因:golang 正则不支持lookaround,可以用组匹配
```
func Test_1(t *testing.T){
var re = regexp.MustCompile(`[^-](\d)`)
content:=`-1,1,2,-2,3,4`
for _,match:=range re.FindAllStringSubmatch(content,-1){
println(match[1])
}
}
```
#3
更多评论