golang 正则表达式
package main import "bytes" import "fmt" import "regexp" func main() { //这个测试一个字符串是否符合一个表达式。 match, _ := regexp.MatchString("p([a-z]+)ch", "peach") fmt.Println(match) //上面我们是直接使用字符串,但是对于一些其他的正则任务,你需要使用 Compile 一个优化的 Regexp 结构体。 r, _ := regexp.Compile("p([a-z]+)ch") //这个结构体有很多方法。这里是类似我们前面看到的一个匹配测试。 fmt.Println(r.MatchString("peach")) //这是查找匹配字符串的。 f...阅读全文