regexp
This commit is contained in:
parent
acce30cea1
commit
ad4eba0796
3 changed files with 114 additions and 0 deletions
17
ass3/zbirnik/parsing/test.go
Normal file
17
ass3/zbirnik/parsing/test.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pattern := regexp.MustCompile(`o\w*g`)
|
||||
fmt.Println(pattern.FindString("oogenesis")) // returns ""
|
||||
fmt.Println(pattern.FindString("ck")) // returns "ook"
|
||||
fmt.Println(pattern.FindString("oocyst")) // returns ""
|
||||
fmt.Println(pattern.FindString("book")) // returns "ook"}
|
||||
match, what := regexp.MatchString("p([a-z]+)ch", "peach")
|
||||
fmt.Println(match)
|
||||
fmt.Println(what)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue