Delphi – Extract multiple substrings from a string

Home / Uncategorized / Delphi – Extract multiple substrings from a string

Question:
I have a string like this
";;;Caption=C:;FreeSpace=103571001344;Size=162527178752;;;Caption=D:;FreeSpace=129889742848;Size=336805752832;;;Caption=V:;FreeSpace=516807241728;Size=1000207282176;;;;

How can I extract each partition data into a variable so that I obtain something like this:partition_1:=’Caption=C:;FreeSpace=103571001344;Size=162527178752′;
partition_2:=’Caption=D:;FreeSpace=129889742848;Size=336805752832′;
partition_n:=’Caption=V:;FreeSpace=516807241728;Size=1000207282176′;

Thank you!


Answer:
This question applies to you as well. Basically, use TStringList, set LineBreak property to 3 semicolons (;;;) and Text property to your string.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *