The example of this article describes the use of Delphi string separation functions. Share to everyone for your reference. The implementation methods are as follows:
This instance enables you to separate the string s into several strings based on the representation of the string separator, in the list of Rs strings, as follows:
Copy Code code as follows:
Procedure SeparateTerms2 (s:string; Separator:string;var rs:tstringlist);
Var
astr:string;
Idx:integer;
asubstr:string;
Begin
ASTR: = Trim (s);
While Pos (Separator, ASTR) > 0 Do
Begin
IDX: = Pos (Separator, ASTR);
ASUBSTR: = Copy (AStr, 1, idx-1);
Rs. ADD (ASUBSTR);
ASTR: = Copy (AStr, idx + 1, Length (ASTR));
End
If astr+ ' a ' <> ' a ' then Rs. ADD (ASTR); If the remaining string exists, it is stored in the string list
End
I hope this article will help you with the Delphi program design.