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
+14.6k Golang : Execute function at intervals or after some delay
+17.1k Golang : XML to JSON example
+30.4k Golang : How to verify uploaded file is image or allowed file types
+12.3k Golang : Display list of countries and ISO codes
+7.1k Golang : Array mapping with Interface
+12.2k Golang : Simple client-server HMAC authentication without SSL example
+5.4k Unix/Linux : How to archive and compress entire directory ?
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+33.6k Golang : How to check if slice or array is empty?
+16.4k Golang : Test floating point numbers not-a-number and infinite example
+19.5k Golang : How to Set or Add Header http.ResponseWriter?