Logo

Programming-Idioms

History of Idiom 39 > diff from v3 to v4

Edit summary for version 4 by :

Version 3

2015-08-01, 17:50:55

Version 4

2015-08-11, 12:29:34

Idiom #39 Check if string contains a word

Set boolean ok to true if string word is contained in string s as a substring, or to false otherwise.

Idiom #39 Check if string contains a word

Set boolean ok to true if string word is contained in string s as a substring, or to false otherwise.

Imports
import "strings"
Code
ok := strings.Contains(s, word)
Origin
http://golang.org/pkg/strings/#Contains
Demo URL
http://play.golang.org/p/NMIIHMDcYt