Golang regexp.MatchReader() function example
package regexp
Golang regexp.MatchReader() function usage example.
package main
import (
"bytes"
"fmt"
"io"
"regexp"
)
func main() {
var reader io.RuneReader
reader = bytes.NewReader([]byte("黄"))
r1, _, _ := reader.ReadRune() // read 1 rune
fmt.Println(r1)
fmt.Println(reader)
// regular expression pattern
match, err := regexp.MatchReader("黄", reader)
if err != nil {
fmt.Println(err)
}
fmt.Println("Matched ? : ", match)
}
Output :
40644
&{[233 187 132] 3 0}
Matched ? : false
Reference :
Advertisement
Something interesting
Tutorials
+5.8k Linux : Disable and enable IPv4 forwarding
+6.5k Golang : Calculate diameter, circumference, area, sphere surface and volume
+6.2k Golang : Calculate US Dollar Index (DXY)
+5.6k Python : Print unicode escape characters and string
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+8.6k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+6.6k Golang : Warp text string by number of characters or runes example
+12.7k Golang : Sort and reverse sort a slice of bytes
+4.7k Unix/Linux : How to pipe/save output of a command to file?
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+11.6k Golang : Convert(cast) float to int
+41k Golang : How to check if a string contains another sub-string?