Created
March 16, 2012 13:20
-
-
Save huyderman/2050039 to your computer and use it in GitHub Desktop.
C# Normalize Newline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.RegularExpressions; | |
public static class StringHelpers { | |
private const char _cr = '\u000D'; | |
private const char _lf = '\u000A'; | |
private const string _crlf = _cr + _lf; | |
private static Regex _crlfRegex = new Regex(_cr + '|' + _lf + '|' + _crlf); | |
public static string NormalizeNewline(this string str){ | |
return _crlfRegex.Replace(str, "\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment