Skip to content

Instantly share code, notes, and snippets.

@stevedomin
Created October 30, 2012 15:53
Show Gist options
  • Save stevedomin/3981102 to your computer and use it in GitHub Desktop.
Save stevedomin/3981102 to your computer and use it in GitHub Desktop.
Flags for Go RegExp
package main
import "fmt"
import "regexp"
func main() {
str := "a\nb"
fmt.Println(str)
regexWithFlag := regexp.MustCompile("(?m)^[a]\\n?^[b]")
regexWithoutFlag := regexp.MustCompile("^[a]\\n?^[b]")
fmt.Println(regexWithFlag.MatchString(str))
fmt.Println(regexWithoutFlag.MatchString(str))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment