summaryrefslogtreecommitdiff
path: root/sandpit/test_regexp.go
blob: 5ae1d882e5767bcb8633d538cedf7227bfbfdaab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main

import(
	"regexp"
	"log"
)


func main (){

	pattern := ".*"
	str := "my_string"

	matched, err := regexp.MatchString(pattern, str)

	if err != nil {
		log.Fatal("Error matching string: ", err)
	}

	if matched {
		log.Printf("Yes! '%s' matched '%s'\n", str, pattern)
	} else {
		log.Printf("Bad luck!\n")
	}

}