Added 'example' file that contains testable examples
parent
2a9ae0b68a
commit
7c4538a259
@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue