Golang fmt.Sscanf() function example
package fmt
Sscanf scans the argument string, storing successive space-separated values into successive arguments as determined by the format. It returns the number of items successfully parsed.
Golang fmt.Sscanf() function usage example
package main
import "fmt"
func main() {
str := "我的名字是 (my name is) : Golang , I'm 5 years old now"
var name string
var age int
// WARNING : the comma must be separated by a space
// %s , OK
// %s, NOT OK
fmt.Sscanf(str, "我的名字是 (my name is) : %s , I'm %d years old now", &name, &age)
fmt.Printf("%s %d\n", name, age)
}
Output :
Golang 5
Reference :
Advertisement
Something interesting
Tutorials
+9.3k Golang : How to get ECDSA curve and parameters data?
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+17.9k Golang : Qt image viewer example
+11.3k Golang : Intercept and process UNIX signals example
+5.2k Python : Create Whois client or function example
+31.1k Golang : Calculate percentage change of two values
+21.2k Golang : Convert(cast) string to rune and back to string example
+8.5k PHP : How to parse ElasticSearch JSON ?
+13.4k Golang : Increment string example
+6.7k Golang : Reverse by word
+17.6k Golang : delete and modify XML file content