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