Issue
This Content is from Stack Overflow. Question asked by Mariusz Jędrzejewski
Is there any simple way to split a block of text (no matter of form, may by List<string>
or string[]
array) in C#? I’m kind of newbie and looking for solution…
Input form is something of:
Not important line 1
Not important other line
FIXED BOUNDARY
Line 1 for chunk 1
Line 2 for chunk 1
...
Line n for chunk 1
FIXED BOUNDARY
Line 1 for chunk 2
Line 2 for chunk 2
...
Line n for chunk 2
FIXED BOUNDARY
Line 1 for chunk 3
...
Repeated for end of input lines
In the end, I need to get List<List<string>>
or List<string[]>
with chunks: each element of list should contains all lines belongs to chunk from 1 to n (including boundary or not: it doesn’t matter):
Chunk 1:
Line 1 for chunk 1
Line 2 for chunk 1
...
Line n for chunk 1
Chunk 2:
Line 1 for chunk 2
Line 2 for chunk 2
...
Line n for chunk 2
and so on. The number of chunks may vary, so I don’t know how many chunks may be in input string list. How should I split it? Is there any library for that kind of text transformation? Please help guys…
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.