如果找到一个字符串包含在C ++字符(可以提升) [英] Find if a string contains a character in C++ (boost allowed)

查看:95
本文介绍了如果找到一个字符串包含在C ++字符(可以提升)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个字符串,我想找到一个特定的字符(如|)是present与否,什么是这样做的最好最快的方法?我知道字符串找到implementation.I现在要求比这更快的实现。

Suppose I have a string and I want to find whether a specific character (like '|') is present or not, what is the best and fastest technique to do so? I know string find implementation.I am asking for even faster implementation than this one.

推荐答案

使用找到:<一href=\"http://stdcxx.apache.org/doc/stdlibref/basic-string.html#idx350\">http://stdcxx.apache.org/doc/stdlibref/basic-string.html#idx350

if (str.find('|') != std::string::npos)
{
    // ...
}

这篇关于如果找到一个字符串包含在C ++字符(可以提升)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆