Answers for "golang find in string"

Go
1

golang find string in string

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.Contains("Assume", "Ass"))

	fmt.Println(strings.ContainsAny("team", "i"))
	fmt.Println(strings.ContainsAny("Hello", "aeiou&y"))

	fmt.Println(strings.HasPrefix("Hello World", "Hello"))
	fmt.Println(strings.HasSuffix("Hello World", "World"))
}
Posted by: Guest on December-18-2020
1

golang find in string

// 1. Contains
res := strings.Contains(str, substr)
fmt.Println(res) // true
Posted by: Guest on August-20-2020

Browse Popular Code Answers by Language