title: How to count the number of paragraphs in a string in C#
body: <p>I'm trying to count the number of paragraphs in a string in C#.</p>
  
  <p>I'm defining a paragraph as a block of text whose parts may be separated by a new line. Paragraphs must be separated by two or more new line. So:</p>
  
  <pre>
  This is a paragraph.
  
  This
  is
  a
  paragraph.
  
  
  
  This is a paragraph.
  </pre>
  
  <p>My first thought was to separate the string through <code>\n\n</code> and then count the parts, but this doesn't work properly when there is more than one line-space separating paragraphs, at the beginning and end of files, or if the file only has one line.</p>
  
  <p>How can I accurately get the number of paragraphs in a string, either through a regular expression or through another method?</p>