0
点赞
收藏
分享

微信扫一扫

C++代码片段01 - 字符串中查找是否有某个字符

萧让听雪 2022-10-09 阅读 78



<span style="font-size:18px;">if( third_name.find('*')!=string::npos || third_name.find('@')!=string::npos ){
printf("third_name[%s] is a email or a mobilenum", third_name.c_str());
return -1;
}</span>


查到一个string 字符串中知否有 * 字符,或者有 @ 字符。 注意点是 string::npos 代表一个不存在的位置。 所以没有不存在,就是存在的意思。

举报

相关推荐

0 条评论