presuffix.go 331 B

1234567891011121314
  1. package main
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. func main() {
  7. var str string = "This is an example of a string"
  8. fmt.Printf("T/F? Does the string \"%s\" have prefix %s? ", str, "Th")
  9. fmt.Printf("%t\n", strings.HasPrefix(str, "Th"))
  10. }
  11. // Output: T/F? Does the string "This is an example of a string" have prefix Th? true