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.

https://regex101.com/r/gu4ag0/1


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -