ReplaceText
简述
字符串的部分替换。将一个字符串Atext中第一次遍历时存在的AFromText全部替换为AToText部分。本函数不支持多语言。
注意:这种判定是基于大小写不敏感,并且这种替换不是递归处理的,就是说,替换一遍以后不再寻找匹配的AFromText再次替换成AtoText字符串。
ReplaceText(AText; AFromText; AToText: String): String;
名称 | 类型 | 说明 |
---|
AText | String | 字符串类型,源串 |
AFromText | String | 字符串类型,被替换内容 |
AToText | String | 字符串类型,替换内容 |
返回 | String |
字符串 |
AText := "The first letter will be replaced by \'one\', but the second letter won't.";
AFromText := "letter";
AToText := "one";
Return ReplaceText(AText, AFromText, AToText);
//输出:The first one will be replaced by 'one', but the second one won't.n