I have an array of substrings and a slice of strings. I want to check if the string contains any of the substrings in the mySliceOfSubstrings slice.
mySliceOfSubstrings := []string{"hello", "world"}
mySliceOfStringsToCheck := []string{"hello mars", "hey mars"}
Is there a better way of doing it the below way of putting a loop inside a loop?
for _, string := range mySliceOfStringsToCheck {
for _, substring := range mySliceOfSubstrings {
result := strings.Contains(string, substring)
}
}
What if I wanted to check the string against two different slice of substrings?