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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -