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
+8.8k Golang : Executing and evaluating nested loop in html template
+19k Golang : Padding data for encryption and un-padding data for decryption
+12.8k Golang : http.Get example
+10.6k Golang : ISO8601 Duration Parser example
+6k Golang : How to verify input is rune?
+13.4k Golang : Verify token from Google Authenticator App
+12.3k Golang : How to check if a string starts or ends with certain characters or words?
+5.3k Golang : Get FX sentiment from website example
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+26.6k Golang : Encrypt and decrypt data with AES crypto