Logo

Programming-Idioms

History of Idiom 39 > diff from v38 to v39

Edit summary for version 39 by hamid914:
New Cpp implementation by user [hamid914]

Version 38

2018-12-17, 18:33:51

Version 39

2019-02-16, 08:59:52

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
#include <string>
Code
ok = s.find(word) != std::string::npos;
Doc URL
http://www.cplusplus.com/reference/string/string/find/
Origin
https://stackoverflow.com/a/2340309/777769
Demo URL
http://cpp.sh/8i3k