. 匹配多行,匹配包括 re := regexp.MustCompile(`(?s)i(.*?)u`) fmt.Println(re.MatchString("i\nlove\nu")) // true // 部分使用 s 模式,下同 re := regexp.MustCompile(`i(?s:.*?)l(.*)`) // 只有第一个括号中使用了s模式 fmt.Println(re.FindString("i \nlove\n u")) // i\nlove 忽略大小写 re := regexp.MustCompile(`(?i)love`) fmt.Println(re.MatchString("i\nLOVE\nu")) // true 多行使用^ $匹配行首和行尾 re := regexp.MustCompile(`(?m)^love$`) fmt.Println(re.MatchString("i\nlove\nu")) // true……

阅读全文