The KillFiller function can remove a given character from a string.
function KillFiller(Code, Filler: char; S: String):String;
This function removes all character fillers that appear in text S. The behavior of this function is determined by code.
The following values apply to the code:
|L||Deletes all characters that correspond to fillers from the left until the first character that does not correspond to more fillers.|
|R||Deletes all characters that correspond to fillers from the right until the first character that does not correspond to more fillers.|
|B||Corresponds to a combination of L and R. The character Filler is deleted from both sides of text S until the first character that no longer corresponds to Filler.|
|A||Deletes all characters in the text S.|
var S1: String; S2: String; begin S1:='***This is ** a text***'; S2:=KillFiller('B','*',S1); ShowMessage(s2); end;
Rules to understand the script can be found here.
The text '***This is ** a text***' is assigned to the string variable S1. The KillFiller function deletes all asterisks from the left and right side of the text, since the code is used as'B'. The result is assigned to S2.
ShowMessage shows: This is ** a text