Delphi delimited string using the function

Here comes Delphi string partition function, used according to your needs. . 1, ExtractStrings function ExtractStrings (Separators, WhiteSpace: TSysCharSet; the Content: the PChar; Strings: of TStrings): Integer;  The first parameter is the separator, may be a plurality of, for example, [ ';', ',', ':'] press semicolons, commas, semicolons simultaneously split. The second parameter is the beginning characters are ignored, for example, [ '<', '>', ''], the segmented character, if there is greater than the number at the beginning, is less than the number, or semicolon, is divided out after ignore. The third parameter is a string divided. The fourth parameter returns the number of the divided character string. Note: This function only by dividing a single character, can not be divided by the string. 2, SplitString function SplitString ( const S, the Delimiters:  String): TStringDynArray; The first argument is a string divided. The second parameter is the separator, the separator may comprise a plurality of, for example, ';,:' , You can press the semicolon, comma, semicolon at the same time to split. The return value is the result of segmentation. Note: This function is not in the early Delphi, with similar usage ExtractStrings, fewer parameters, use more convenient, to refer to this unit System.StrUtils



































3, the use of regular expressions TRegEx.Split

function TRegEx.Split (INPUT, pattern:  String): TArray < String>

The first argument is a string divided.

The second parameter is the delimiter.

Note: This function can completely replace the above two functions, the regular expression is powerful, the above two functions can be divided by a few characters, the regular expression can be divided by a string, or string match, need to reference means RegularExpressions, comprising regular expressions in Delphi XE and later versions.

Guess you like

Origin www.cnblogs.com/jijm123/p/12310443.html