This article describes the function usage delphi strings separated by a custom function SeparateTerms2 realized after the split a string into a list of strings function, has some practical value, need friends can refer to the following
This paper describes examples delphi string partition function usage. Share to you for your reference. Specific method is as follows:
This example may be implemented in accordance with the string representation of the string s Separator divided into a plurality of strings, a list of strings into rs, the specific 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 ' the then rs.Add (ASTR); // If the remaining string is present, it is stored in the list of strings End ;