The following is a description of the Delphi string segmentation function, according to your needs to use.
1, Extractstrings
function extractstrings (separators, whitespace:tsyscharset; Content:pchar; strings:tstrings): Integer;
The first argument is a delimiter, which can be multiple, for example ['; ', ', ', ': '] can be split at the same time by semicolons, commas, and semicolons.
The second argument is a character that is ignored at the beginning, such as [' < ', ' > ', ' '], the character being split, and if it starts with a greater than, less than, or semicolon, it is omitted after being split.
The third argument is a string that is split.
The fourth parameter returns the number of separated strings.
Note: This function can only be split by a single character and cannot be split by a string.
2, Splitstring
function splitstring (const S, delimiters:string): Tstringdynarray;
The first argument is a string that is split.
The second argument is a delimiter that can contain multiple delimiters, such as ';,: ', which can be split at the same time by semicolons, commas, and semicolons.
The return value is the result of the split.
Note: This function is not in the early Delphi, similar to the use of extractstrings, fewer parameters, more convenient to use, to refer to this unit system.strutils
3, the use of regular-type tregex.split
function Tregex.split (input, pattern:string): tarray<string>
The first argument is a string that is split.
The second argument is a delimiter.
Note: This function can completely replace the above two functions, the regular function is very powerful, the above two functions can only be divided by a certain number of characters, the regular formula can be separated by a string, or matching string, need to refer to the unit RegularExpressions, in the Delphi The XE and later versions contain the regular style.