Reputation: 41007
I was wondering if there is a native C++ (or STL/Boost) function which will search a CString for a specified string?
e.g.
CString strIn = "Test number 1";
CString strQuery = "num";
bool fRet = SomeFn(strIn, StrQuery);
if( fRet == true )
{
// Ok strQuery was found in strIn
...
I have found a small number of functions like CompareNoCase IndexOf etc... but so far they don't really do what I want them to do (or use CLR/.Net)
Thanks!
Upvotes: 2
Views: 20176
Reputation: 52679
CString::Find() is what you want, one of the overloads does sub-string searching.
CString strIn = "test number 1";
int index = strIn.Find("num");
if (index != -1)
// ok, found
Upvotes: 15
Reputation: 6187
Have you tried CString::Find?
It's not STL or boost but since you have two CString's it seems the most reasonable method to use.
Upvotes: 2