lean into examples

This commit is contained in:
Mark McGranaghan
2012-10-09 21:02:12 -07:00
parent 5d1775bdaa
commit 8daa226a48
130 changed files with 4 additions and 4 deletions

19
examples/regexs/regexs.go Normal file
View File

@@ -0,0 +1,19 @@
package main
import "regexp"
import "fmt"
func main() {
m1, _ := regexp.MatchString("p[a-z]+ch", "apple")
m2, _ := regexp.MatchString("p[a-z]+ch", "peach")
fmt.Println(m1)
fmt.Println(m2)
r1, _ := regexp.Compile("p[a-z]+ch")
fmt.Println(r1.MatchString("apple"))
fmt.Println(r1.MatchString("peach"))
}
// todo: more
// todo: gsub with regexp
// todo: rename to "Regular Expressions"

View File

@@ -0,0 +1,5 @@
$ go run regexs.go
false
true
false
true