在 C++ 中搜索 CString
我想知道是否有一个本机 C++(或 STL/Boost)函数可以在 CString 中搜索指定的字符串?
例如,
CString strIn = "Test number 1";
CString strQuery = "num";
bool fRet = SomeFn(strIn, StrQuery);
if( fRet == true )
{
// Ok strQuery was found in strIn
...
我发现了少量函数,例如 CompareNoCase IndexOf 等...但到目前为止,它们并没有真正执行我希望它们执行的操作(或使用 CLR/.Net)
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CString::Find() 是您想要的,重载之一进行子字符串搜索。
CString::Find() is what you want, one of the overloads does sub-string searching.
string::find
string::find
您是否尝试过CString::Find?
它不是 STL 或 boost,但由于您有两个 CString,因此它似乎是最合理的使用方法。
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.