// 替换字符的函数
function ReplaceStr(const ASource, ASub, ANew: String): String;
var
intPos, intLen: Integer;
strValue, strTemp: String;
begin
strValue := '';
strTemp := ASource;
intLen := Length(ASub);
intPos := Pos(ASub, strTemp);
while intPos > 0 do
begin
strValue := strValue + Copy(strTemp, 1, intPos - 1) + ANew;
strTemp := Copy(strTemp, intPos + intLen, Length(strTemp) - intPos - intLen + 1);
intPos := Pos(ASub, strTemp);
end;
if strTemp <> '' then
strValue := strValue + strTemp;
result := strValue;
end;
function ReplaceStr(const ASource, ASub, ANew: String): String;
var
intPos, intLen: Integer;
strValue, strTemp: String;
begin
strValue := '';
strTemp := ASource;
intLen := Length(ASub);
intPos := Pos(ASub, strTemp);
while intPos > 0 do
begin
strValue := strValue + Copy(strTemp, 1, intPos - 1) + ANew;
strTemp := Copy(strTemp, intPos + intLen, Length(strTemp) - intPos - intLen + 1);
intPos := Pos(ASub, strTemp);
end;
if strTemp <> '' then
strValue := strValue + strTemp;
result := strValue;
end;
“严格匹配整个substr而非子串substr的第一个字符”
看得出你的意思是说明以上的描述是对stringreplace的描述,但是这句话绝对不是一个正确的描述。你的子串substr有几个字符,如果只有一个,那么肯定函数是只对这一个字符进行匹配,如果有几个,stringrelplace也肯定会只替换完全匹配所有字符的,所以我看不出你的描述是何用意。
你最好写出具体的字符来说明,不要用什么##之类的,又不仔细说明是表示单个字符还是多个。
如果是单个,我想你的意思就是说,重复的连续字符只替代一个或者不算匹配,这样就明确了。但是你的那句描述还是不对。
说一下吧,我们再给你想。