Logo

Programming-Idioms

History of Idiom 39 > diff from v30 to v31

Edit summary for version 31 by programming-idioms.org:
New Lua implementation by user [programming-idioms.org]

Version 30

2016-11-11, 20:07:45

Version 31

2016-11-11, 20:16:57

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.

Code
ok = s:find(word, 1, true) ~= nil
Comments bubble
This checks that the found index is not nil.