From the course: Learning the Go Standard Library

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

String searching

String searching - Go Tutorial

From the course: Learning the Go Standard Library

Start my 1-month free trial

String searching

- [Tutor] All right so now that we've had a chance to try out some of the basic string functions. Let's turn our attention to string searching and for this example, we're going to need to open the string search go file in the start version of our code. So down here in the search folder, I'll open up this example and we'll start by uncommenting these import statements. And the first functions that we're going to look at are the Contains and ContainsAny function and I'm going to need my S variable here for this. So we can use the contains function to see if a sub-string is contained within a given string. So once again, I'll use my format and I'll use PrintLine and I'm going to printline whether strings.Contains returns true for S and if it contains the word jump and this is the string that we're looking at, we can see that it's right there, so this should work, all right. And we can use ContainsAny to see if any of…

Contents