-4

I have a string like this from my memo1:

model,"GHN-888",id,"00000000",date,"04-21-2016",type,1

how can I make it like this:

Model = GHN-888 id = 00000000 date = 04/21/2016 type = 1

Is this possible? Thanks in advance.

Erik A
  • 28,352
  • 10
  • 37
  • 55

1 Answers1

1

You can use a TStringList to parse this line. Has a simple method for divide strings using the properties, Delimiter, DelimitedText and StrictDelimiter.

See the help about this properties.

You can use a code like this:

var
  TS:TStringList;
begin
  TS := TStringList.Create();
  TS.StrictDelimiter := True;
  TS.Delimiter := ',';
  TS.DelimitedText := 'model,"GHN-888",id,"00000000",date,"04-21-2016",type,1';

Now (after assigning the DelimitedText property) the TStringList has divided the text using the char ',' And you have 8 lines with this values:

Model
GHN-888
id
00000000
date
04-21-2016
type
1

Now it is easy to obtain the values ​​individually, with a loop o using TS[0], TS1, TS[2]...