Unfold string array

Teo x at x.com
Sun Jan 5 08:21:54 UTC 2020


I couldn't find by searching this forum the way to do that, so I 
thought it is better to ask and learn.

The data I am trying to unfold is in the form of string array 
read from a file line by line, like this:

string[] lines =
[
"key1: valueA",
"key2: valueB",
"key3: valueC",
"\tvalueD",
"<white space>valueE",
"key4: valueF",
]

where <white space> represents some white space character(s). It 
could be TAB or SPACE, etc.

Now, I want to find a way to concatenate valueD to the previous 
element which begins with key3 and afterwards concatenate valueE 
also to the concatenated string for key3.

The rule is that long strings are folded when written to the file 
and folded lines always begin with a white space.

Finally I am going to use assocArray to construct an associative 
array.

All advises are welcome
Thank you!



More information about the Digitalmars-d-learn mailing list