Split the string into a one-dimensional array in Delphi

zhaozj2021-02-17  68

The processing of strings is often used in many places. For a string, you can use the following method.

TYPE USERARRY = array of string;

Function TForm1.Split (String; Dot: Char): Userarray; Var Str: Userarray; I, J: Integer; Begin i: = 1; J: = 0; SETLENGTH (STR, 255); While Pos (DOT, s)> 0 Do Begin Str [J]: = COPY (S, I, POS (DOT, S) -i); i: = POS (DOT, S) 1; S [I-1]: = CHR ( ORD (DOT) 1); J: = J 1; End; Str [J]: = COPY (S, I, Strlen (PCHAR (S)) - i 1); Result: = Str; End;

You can transform, let it reach the results you need.

转载请注明原文地址:https://www.9cbs.com/read-31142.html

New Post(0)