func ExampleRegexp_Match() {
re := regexp.MustCompile(`foo.?`)
fmt.Println(re.Match([]byte(`seafood fool`)))
+ fmt.Println(re.Match([]byte(`something else`)))
// Output:
// true
+ // false
}
func ExampleRegexp_FindString() {
}
func ExampleRegexp_NumSubexp() {
+ re0 := regexp.MustCompile(`a.`)
+ fmt.Printf("%d\n", re0.NumSubexp())
+
re := regexp.MustCompile(`(.*)((a)b)(.*)a`)
fmt.Println(re.NumSubexp())
// Output:
+ // 0
// 4
}
// [18 33]
// option1: value1
}
+
func ExampleRegexp_FindAllSubmatchIndex() {
content := []byte(`
# comment line
// option2
// value2
}
+
+func ExampleRegexp_FindAllIndex() {
+ content := []byte("London")
+ re := regexp.MustCompile(`o.`)
+ fmt.Println(re.FindAllIndex(content, 1))
+ fmt.Println(re.FindAllIndex(content, -1))
+ // Output:
+ // [[1 3]]
+ // [[1 3] [4 6]]
+}