go regex

package main

import (
    "fmt"
    "regexp"
)

func main() {
    str := "abc123456"
    match, err := regexp.Match("\u4e00", []byte(str))
    fmt.Println(match, err)

    matchstring, err := regexp.MatchString("\\d", str)
    fmt.Println(matchstring, err)

    name, _ := regexp.Compile("\\w{4,6}")
    x := name.Match([]byte(" Abcdefghalfd; hjkadsfjlk " )) 
    fmt.Println (X, ERR) 

    Age: = regexp.MustCompile ( " \\ D " ) 
    fmt.Println (age.Match ([] byte ( " 12345 " ))) 
    fmt.Println ( age.MatchString ( " 12345 " )) 

    fmt.Println ( String (age.ReplaceAll ([] byte ( " my country 1 2 3 4 5 " ), [] byte ( "" )))) 
    fmt.Println (age.Split ( " my country 1 2 3 4 5 " ,7))

}

 

Guess you like

Origin www.cnblogs.com/zhangjian0092/p/12545644.html
Go