public static string[] SplitStringOnLine(string value)
{
if (!string.IsNullOrEmpty(value))
{
value = value.Replace("\r\n", "<br>").Replace("\n", "<br>");
Regex myRegex = new Regex("<br>");
MatchCollection mc = myRegex.Matches(value);
if (mc.Count > 0)
{
int startIndex = 0;
string[] strA = new string[mc.Count + 1];
var i = 0;
foreach (Match match in mc)
{
if (startIndex == match.Index - startIndex)
{
strA[i] = string.Empty;
}
else
{
strA[i] = value.Substring(startIndex, match.Index - startIndex);
}
startIndex = match.Index + 4;
if (mc.Count == i + 1)
{
strA[i + 1] = value.Substring(startIndex, value.Length - startIndex);
}
i++;
}
return strA;
}
}
return new string[1]{value};
}
{
if (!string.IsNullOrEmpty(value))
{
value = value.Replace("\r\n", "<br>").Replace("\n", "<br>");
Regex myRegex = new Regex("<br>");
MatchCollection mc = myRegex.Matches(value);
if (mc.Count > 0)
{
int startIndex = 0;
string[] strA = new string[mc.Count + 1];
var i = 0;
foreach (Match match in mc)
{
if (startIndex == match.Index - startIndex)
{
strA[i] = string.Empty;
}
else
{
strA[i] = value.Substring(startIndex, match.Index - startIndex);
}
startIndex = match.Index + 4;
if (mc.Count == i + 1)
{
strA[i + 1] = value.Substring(startIndex, value.Length - startIndex);
}
i++;
}
return strA;
}
}
return new string[1]{value};
}