The ContainsAny() Function returns true, if any 1 letter of the searched substring matches.
Let us clear with the below example
package main
import "fmt"
import "strings"
func main() {
x := "Beautiful"
y := strings.ContainsAny(x, "tp")
if (y == true) {
fmt.Println("Any one of the letter 't' or 'p' is present in the String")
} else {
fmt.Println("None of the letter 't' or 'p' is present in the String")
}
}
In the above code, we have declared a String 'Beautiful' and assigned it to a variable 'x'.
-Function1.png)
And we would be searching if any 1 letter, either 't' or 'p' is present in the String "Beautiful".
And we can see that the letter 't' is present in the String "Beautiful".
-Function2.png)
And the below output is printed.