有谁能举例说明一下StringReplace()函数的用法吗?谢谢!在线等,下午2:00结贴。

deepWATERblue 2003-12-12 12:19:05
有谁能举例说明一下StringReplace()函数的用法吗?谢谢!越详细越好!
...全文
374 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
deepWATERblue 2003-12-12
  • 打赏
  • 举报
回复
举个例子啊!!!
deepWATERblue 2003-12-12
  • 打赏
  • 举报
回复
什么哦?照抄帮助说明哦?
wolf2005 2003-12-12
  • 打赏
  • 举报
回复
还能再详细吗?
dulei115 2003-12-12
  • 打赏
  • 举报
回复
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;

TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);

rfReplaceAll Replace all occurrences. If this flag is not present, only the first occurrence of the target substring is replaced.
rfIgnoreCase Match occurrences of the substring case-insensitively. If this flag is not present, only case-sensitive matches are considered.
mingjianzeng2003 2003-12-12
  • 打赏
  • 举报
回复
学习
deepWATERblue 2003-12-12
  • 打赏
  • 举报
回复
哈哈,,太好了。2点我准时结贴。
dulei115 2003-12-12
  • 打赏
  • 举报
回复
StringReplace('AaaaAaa','a','b',[]) = 'AbaaAaa'
StringReplace('AaaaAaa','a','b',[rfReplaceAll]) = 'AbbbAbb'
StringReplace('AaaaAaa','a','b',[rfIgnoreCase]) = 'baaaAaa'
StringReplace('AaaaAaa','a','b',[rfReplaceAll,rfIgnoreCase]) = 'bbbbbbb'
dulei115 2003-12-12
  • 打赏
  • 举报
回复
Flags: TReplaceFlags
[] 替换第一个,区分大小写
[rfReplaceAll]替换全部,区分大小写
[rfIgnoreCase]替换第一个,不区分大小写
[rfReplaceAll,rfIgnoreCase]替换全部,不区分大小写
nxfbccu 2003-12-12
  • 打赏
  • 举报
回复
var
str:string;
begin
str:='we have we have we have';
str:=StringReplace(str, 'we', 'rr',[rfIgnoreCase]);//将第一个'we'替换为'rr'
str:=StringReplace(str, 'we', 'rr',[rfReplaceAll]);//将所有的'we'替换为'rr'
hongqi162 2003-12-12
  • 打赏
  • 举报
回复
procedure TfrmMain.RemoveSpace(Str: String):string;
begin
str := StringReplace(str, ' ', '', [rfReplaceAll]); //去空格
str := StringReplace(str, #7, '', [rfReplaceAll]);
str := StringReplace(str, #13#10, '', [rfReplaceAll]);
Result:=str;
end;

5,927

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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