怎么从右边开始搜索某个字符第一次出现的位置?

huang_2 2003-02-19 06:37:43
字符串查找 比如在 "ABCDFR.txt" 从右边开始里找 . 第一次出现的位置用什么函数呀,请教
...全文
881 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzhong2 2003-02-19
  • 打赏
  • 举报
回复
int i;
AnsiString s = "ABCDFR.txt";

i=s.LastDelimiter("." );

//i=7
zzhong2 2003-02-19
  • 打赏
  • 举报
回复
AnsiString::LastDelimiter

Returns the index of the rightmost character that matches any character in the delimiters string.

int __fastcall LastDelimiter(const AnsiString& delimiters) const;

Description

LastDelimiter returns the byte index in this AnsiString of the rightmost whole character that matches any character in delimiters except NULL The AnsiString may contain multibyte characters; delimiters must contain only single byte non-NULL characters.

Note: Some characters must still be represented using a leading backslash. For example:

AnsiString s = "c:\\filename.ext";

s.LastDelimiter("\\.:" );

returns 12.
whitelion 2003-02-19
  • 打赏
  • 举报
回复
pos就是
gk0205 2003-02-19
  • 打赏
  • 举报
回复
extern PACKAGE char * __fastcall StrRScan(const char * Str, char Chr);
zihan 2003-02-19
  • 打赏
  • 举报
回复
StrRScan(const *char,const *char);
halibut 2003-02-19
  • 打赏
  • 举报
回复
AnsiString str="ABCDFR.txt";
int pos;
pos = str.Pos(".");
if(pos>0 && str.SubString(pos + 1,str.Length()-pos).Pos(".")==0)
{
//OK
}
else
{
//NO
}

13,825

社区成员

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

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