如何实现对文件中一些字符用其他字符替换

devie 2002-11-19 09:46:52
如何实现对文件中一些字符用其他字符替换,例如文件中存在“asd”我要将它替换为“qwerwetrert”。
...全文
74 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
invalid 2002-12-04
  • 打赏
  • 举报
回复
#include <StrUtils.hpp>
invalid 2002-12-04
  • 打赏
  • 举报
回复
1.不区分大小写
extern PACKAGE AnsiString__fastcall AnsiReplaceText(const AnsiString AText, const AnsiString AFromText, const AnsiString AToText);

Description

Call AnsiReplaceText to scan the string specified by AText and replace all occurrences of the string specified by AFromText with the string specified by AToText. Occurrences of AFromText are identify by a case-insensitive comparison that uses the current Windows locale. The identification of substrings is not recursive: if the substitution of AToText results in a new match for AFromText, that match is not replaced.

2.区分大小写
extern PACKAGE AnsiString__fastcall AnsiReplaceStr(const AnsiString AText, const AnsiString AFromText, const AnsiString AToText);

Description

Call AnsiReplaceStr to scan the string specified by AText and replace all occurrences of the string specified by AFromText with the string specified by AToText. Occurrences of AFromText are identify by a case-sensitive comparison. The identification of substrings is not recursive: if the substitution of AToText results in a new match for AFromText, that match is not replaced.

yuyulily 2002-12-04
  • 打赏
  • 举报
回复
StringReplace
Returns an AnsiString with occurrences of one substring replaced by another substring.

Unit

Sysutils

Category

string handling routines

enum Sysutils__93 { rfReplaceAll, rfIgnoreCase };

typedef Set<Sysutils__93, rfReplaceAll, rfIgnoreCase> TReplaceFlags;

extern PACKAGE AnsiString __fastcall StringReplace(const AnsiString S, const AnsiString OldPattern, const AnsiString NewPattern, TReplaceFlags Flags);

Description

StringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string, specified by S, may contain Multibyte characters.

If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.

If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.
devie 2002-11-21
  • 打赏
  • 举报
回复
StringReplace?
yuyulily 2002-11-19
  • 打赏
  • 举报
回复
StringReplace
copy_paste 2002-11-19
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1171/1171303.xml?temp=.7230646

那贴子已经将内容读出来,并进行替换了,然后你将它再写入就是了。
favorit 2002-11-19
  • 打赏
  • 举报
回复
你试试BCB的ReplaceDialog控件,具体我也没用过

13,824

社区成员

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

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