Created
October 30, 2012 15:53
-
-
Save stevedomin/3981102 to your computer and use it in GitHub Desktop.
Flags for Go RegExp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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