title: Which is the most efficent of matching and replacing with an identifier every three new lines?
body: <p>I am working with some .txt files that doesn't have structure (they are messy), they represent a number of pages. In order to give them some structure I would like to identify the number of pages since the file itself doesn't have them. This can be done by replacing every three newlines with some annotation like: </p>
  
  <pre><code>\n
      page: N
  \n
  </code></pre>
  
  <p>Where <code>N</code> is the number. This is how my files look like, and I also tried with a simple <a href="http://pastebin.com/K0PdJ1TG" rel="nofollow"><code>replace</code></a>. However, this function confuses and does not give me the expected format which would be something like <a href="http://pastebin.com/ZCw63uyE" rel="nofollow">this</a>. Any idea of how to replace the spaces with some kind of identifier, just to try to parse them and getting the position of some information (page)?.</p>
  
  <p>I also tried this:</p>
  
  <p>import re</p>
  
  <pre><code>replaced = re.sub('\b(\s+\t+)\b', '\n\n\n', text)
  print (replaced)
  </code></pre>