The following function will remove all occurrences of a given character from the string passed to it: function StrRemoveChar(sStr : string; sChar : string) : string var i, j : number; sTemp : string; begin j := 1; for i := 1 to Strlen(sStr) do if sStr[i] = Chr(GetChar(sChar, 1)) then // do nothing else sTemp[j] := sStr[i]; j := j + 1; end; end; sStr := sTemp; StrRemoveChar:= sStr; end StrRemoveChar; For example, you can remove all blanks from the string "This is a test" as follows: sString := "This is a test"; StrRemoveChar(sString, " "); Print(sString); Old KB# 18493
↧