c# - Flexible paragraph counting -


i've looked through this question, , i've tried modifying answer, i'm still stumped.

i need count paragraphs in string. however, paragraphs can separated number of newline characters (1-n newlines), start or without tabs (0-n tabs), , empty lines contain empty characters shouldn't counted (this part that's tripping me up).

example document:

first paragraph. second paragraph. <tab>the third. <tab> <tab> <tab> <tab>the fourth.  fifth. 

any appreciated.

you can split on tab , newline, , remove empty lines

text.split(new string[] { environment.newline, "\t", "\n" }, stringsplitoptions.removeemptyentries)     .where(x => x.trim() != "") 

see demo: https://dotnetfiddle.net/y79qjg


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -