草庐IT

20160101

全部标签

regex - 如何匹配 golang 正则表达式中的字符或字符串结尾?

我无法解决(在golang中)在正则表达式中如何匹配字符、分隔符或字符串结尾的问题。以下几乎是我想要的:url:="test20160101"ifi,_:=regexp.MatchString("[-a-zA-Z/]20[012]\\d[01]\\d[0123]\\d[-a-zA-Z/]",url);i==true{t:=regexp.MustCompile("[-a-zA-Z/](20[012]\\d[01]\\d[0123]\\d)[-a-zA-Z/]").FindStringSubmatch(url)[1]fmt.Println("match:",t)}https://play.

regex - 如何匹配 golang 正则表达式中的字符或字符串结尾?

我无法解决(在golang中)在正则表达式中如何匹配字符、分隔符或字符串结尾的问题。以下几乎是我想要的:url:="test20160101"ifi,_:=regexp.MatchString("[-a-zA-Z/]20[012]\\d[01]\\d[0123]\\d[-a-zA-Z/]",url);i==true{t:=regexp.MustCompile("[-a-zA-Z/](20[012]\\d[01]\\d[0123]\\d)[-a-zA-Z/]").FindStringSubmatch(url)[1]fmt.Println("match:",t)}https://play.