I have some question about "find specific string from between two string and get into list".
I have a string like that :
-begin-
code:[264]
Name:[1]
Name:[2]
Name:[3]
-end-
code:[264]
Name:[1]
Name:[4]
code:[264]
Name:[6]
-begin-
Name:[6]
code:[264]
Name:[7]
Name:[8]
Name:[1]
-end-
I want to split string "Name:" between "-begin-" to "-end-" into List like as below,
list<1>
Name:[1]
Name:[2]
Name:[3]
list<2>
Name:[6]
Name:[7]
Name:[8]
Name:[1]
Now I can only split text between "-begin-" to "-end-" into list.
int first = 0;
int last = 0;
int number = 0;
int start = 0;
do {
first = text.IndexOf("-begin-", start);
last = text.IndexOf("-begin-", first + 1);
if (first >= 0 && last >= 0)
{
number = (last - first);
AVPline.Add(text.Substring(first,number).Trim());
start = last + 1;
}
} while (position > 0);
I have no idea to split string "Name:" after split text between "-begin-" to "-end-".
Can somebody help me with this.
Thank You very much.
"-begin-"and"-end-"sequences don't seem to match up in any way with the position of theNamefields. SomeNamefields are inside of a begin/end block, others are not. It's rather haphazard. If your sample data is accurate, then you simply must sit down and write some detailed parsing logic on your own - there is no technical problem (other than the parsing logic) that we can help you with.