You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
507 B
Go
33 lines
507 B
Go
1 day ago
|
package regex_test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"gitea.twomorecents.org/Rockingcool/kleingrep/regex"
|
||
|
)
|
||
|
|
||
|
func ExampleReg_Find() {
|
||
|
regexStr := "b|a"
|
||
|
regexComp := regex.MustCompile(regexStr)
|
||
|
|
||
|
match, _ := regexComp.Find("banana")
|
||
|
fmt.Println(match.String())
|
||
|
|
||
|
// Output: 0 1
|
||
|
}
|
||
|
|
||
|
func ExampleReg_FindAll() {
|
||
|
regexStr := "b|a"
|
||
|
regexComp := regex.MustCompile(regexStr)
|
||
|
|
||
|
matches := regexComp.FindAll("banana")
|
||
|
for _, group := range matches {
|
||
|
fmt.Println(group.String())
|
||
|
}
|
||
|
|
||
|
// Output: 0 1
|
||
|
// 1 2
|
||
|
// 3 4
|
||
|
// 5 6
|
||
|
}
|