怎么样搜索字符串?比如判断ABCDEF中是否包含CDE?

dxgxk 2003-01-13 06:13:51
简单问题:怎么样搜索字符串?比如判断ABCDEF中是否包含CDE?
...全文
34 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
favorit 2003-01-13
  • 打赏
  • 举报
回复
String str,substr;
if(AnsiPos(str,substr)>0)
{
//有
}
else
{
//无
}
东北猫 2003-01-13
  • 打赏
  • 举报
回复
int __fastcall AnsiPos(const AnsiString& subStr) const;

Description

Returns the index in the AnsiString at which the substring subStr begins, where 1 is the first character in the string, 2 is the second character, and so on. If the substring is not contained in the AnsiString, Pos returns 0. This member function is the same as Pos but supports multibyte character strings.

Note: See ByteType for more information about multibyte characters.
halibut 2003-01-13
  • 打赏
  • 举报
回复
if(name.Pos("CDE")>0)
{
//有
}
else
{
//无
}
googoler 2003-01-13
  • 打赏
  • 举报
回复
不考滤效率的话

"abcde".AnsiPos("cde");


-------------------------------------------------------------------
以上所述实属个人胡乱推测,如有雷同,纯属巧合。欢迎各位高手斧正。
仅供参考而已!

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧