$Search: searching for strings

Find the position of a string within another string

Using [strings.Index](<https://golang.org/pkg/strings/#Index>):

https://codeeval.dev/gist/4c312b56d6830c6a5961f876bd0042b3

Find the position of string within another string starting from the end

Above we searched from the beginning of the string. We can also search from the end using [strings.LastIndex](<https://golang.org/pkg/strings/#LastIndex>):

https://codeeval.dev/gist/5678a8bc7d172c4c17e27eb74580fb28

Find all occurrences of a substring

Above, we only found the first occurrence of the substring. Here’s how to find all occurrences:

https://codeeval.dev/gist/16ee87e4a408f7eee71a13dfa441b17c

Check if a string contains another string

Using [strings.Contains](<https://golang.org/pkg/strings/#Contains>):

https://codeeval.dev/gist/5ce0127165d333511302b27334c555e6

Check if a string starts with another string

Using [strings.HasPrefix](<https://golang.org/pkg/strings/#HasPrefix>):

https://codeeval.dev/gist/19a7e8b4d87bda8dc5cb4a6eac6eed10

Check if a string ends with another string

Using [strings.HasSuffix](<https://golang.org/pkg/strings/#HasSuffix>):

https://codeeval.dev/gist/b603359b4d99a88b778d15751c66c53c