Regex match and split string in C# -
i have ascii documents in following format:
[section heading] paragraphs...... [section heading] paragraphs...... ... note: heading text enclosed in specific pattern (e.g.
[]in above example)
i want split file separate sections (each heading , content).
what efficient way parse above document?
using regex.match() can extract headings, not subsequent text content.
using regex.split() can grab content, not related headings.
is possible combine these 2 regex methods parse document? there better ways achieve same?
(\[[^\]]*\])\n([\s\s]*?)(?=\n\[|$) you can try this.grab group 1 , group 2.see demo.
Comments
Post a Comment