Quantcast
Channel:
Viewing all articles
Browse latest Browse all 44070

Wiki Page: How can I remove all occurrences of a particular character from a string?

$
0
0
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

Viewing all articles
Browse latest Browse all 44070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>