Ejemplo n.º 1
0
func main() {
	reg := regex.Compile(`\s+|[-+*/]|\d+(?:\.\d+)?(?:[eE][-+]?\d+)?|\(#{0}+?\)`)
	for _, u := range reg.FindAllStringSubmatch("1+(2-3)*(4/5.33)*((6-7)+8)") {
		for _, v := range u {
			fmt.Print(v, " ")
		}
		fmt.Println("")
	}
}
Ejemplo n.º 2
0
func main() {
	reg := regex.Compile(`(?<!\d)(?:0|1\d{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?)\.#{1}\.#{1}\.#{1}(?::\d{1,5})?`)
	for _, s := range reg.FindAllStringSubmatch("127.0.0.1:8087 255.33.1.2:12345  217.169.209.2:6666  192.227.139.106:7808") {
		fmt.Printf("%-24s", s[0])
		for _, x := range s[1:] {
			fmt.Printf("%-8s", x)
		}
		fmt.Println("")
	}
}
Ejemplo n.º 3
0
func main() {
	reg := regex.Compile(`(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?::(\d{1,5}))?`)
	for _, s := range reg.FindAllString("127.0.0.1:8087 255.33.1.2:12345  217.169.209.2:6666  192.227.139.106:7808") {
		fmt.Printf("%-24s\n", s[0])
	}
}