Check out example codes for "c++ string contains". It will help you in understanding the concepts better.

Code Example 1

if (string1.find(string2) != std::string::npos) {
    std::cout << "found!" << '\n';
}

Code Example 2

word = 'geeks for geeks'
  
# returns first occurrence of Substring 
result = word.find('geeks') 
print ("Substring 'geeks' found at index:", result ) 
  
result = word.find('for') 
print ("Substring 'for ' found at index:", result ) 
  
# How to use find() 
if (word.find('pawan') != -1): 
    print ("Contains given substring ") 
else: 
    print ("Doesn't contains given substring")

Code Example 3

size_t find (const string& str, size_t pos = 0) const;

Learn ReactJs, React Native from akashmittal.com