Golang regular match error report

what is the reason for this and how to modify it?

var reg_pattern = regexp.MustCompile("^(<a>\\d)(\\d)(\\d)\\1\\2\\3$")
    if reg_pattern.MatchString(convert.IntToStr(uid)) {
            return true
        }
panic: regexp: Compile(`^(<a>\d)(\d)(\d)\1\2\3$`): error parsing regexp: invalid escape sequence: `\1`

and what is the reason for this and how to modify it?

var reg_pattern13 = regexp.MustCompile("(?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)|9(?=0)){2,}|(?:0(?=9)|9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){2,})\\d")
        if reg_pattern13.MatchString(convert.IntToStr(uid)) {
            return true
        }
panic: regexp: Compile(`(?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)|9(?=0)){2,}|(?:0(?=9)|9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){2,})\d`): error parsing regexp: invalid or unsupported Perl syntax: `(?=`
Mar.30,2021

\ d , or \\ d ? I recommend that you not use " to wrap the entire expression, but use ` to wrap the expression. The regular expression of


golang does not support backreference.
https://github.com/google/re2.
https://github.com/google/re2.

Menu