在 C++ 中搜索 CString

发布于 2024-07-07 04:51:23 字数 358 浏览 8 评论 0原文

我想知道是否有一个本机 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ゃ懵逼小萝莉 2024-07-14 04:51:23

CString::Find() 是您想要的,重载之一进行子字符串搜索。

CString strIn = "test number 1";
int index = strIn.Find("num");
if (index != -1)
    // ok, found

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
青芜 2024-07-14 04:51:23

您是否尝试过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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文