title: Remove multiple newlines/carriage-returns from a string
body: <p>I'm trying to remove multiple newlines/carriage-returns from a string that may appear in any pattern (the strings come from social network APIs - TW, FB, YT). I was able to remove almost all combinations however I can't seem to remove multiple repetitions of "\r\n" or "\n\r".</p>
  
  <p>What I would like is to have:
      "Line1\r\nLine2\n\n\n\n\n\n\n\nLine3\r\r\r\r\rLine4\r\n\"Line5\"\n\r\n\rLine6\rLine7\r\n\r\nLine8\r\r\r\r\r\r\r\r\n\n\n\rLine9\n\n\n\n\n\r\r\r\r\nLine10\nLine11\n\n\n\n"</p>
  
  <p>become:</p>
  
  <pre><code>Line1
  Line2
  Line3
  Line4
  "Line5"
  Line6
  Line7
  Line8
  Line9
  Line10
  Line11
  </code></pre>
  
  <p>but currently I get:</p>
  
  <pre><code>Line1
  Line2
  Line3
  Line4
  "Line5"
  
  Line6
  Line7
  
  Line8
  Line9
  Line10
  Line11
  </code></pre>
  
  <p>This is the code I have:</p>
  
  <pre><code>NSMutableString *testString = [[NSMutableString alloc]init];
  [testString appendString:@"Line1\r\nLine2\n\n\n\n\n\n\n\nLine3\r\r\r\r\rLine4\r\n\"Line5\"\n\r\n\rLine6\rLine7\r\n\r\nLine8\r\r\r\r\r\r\r\r\n\n\n\rLine9\n\n\n\n\n\r\r\r\r\nLine10\nLine11\n\n\n\n"];
  
  NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\r+)(\\n+)?(\r+)?|(\\n+)(\r+)?(\\n+)?|(\\n\r+)|(\r\\n+)" options:NSRegularExpressionCaseInsensitive error:nil];
  
  [regex replaceMatchesInString:testString options:0 range:NSMakeRange(0, [testString length]) withTemplate:@"\n"];
  </code></pre>