.NET Regex query to search for ONE new line

I have a huge line that looks like this:

"Text
Text
Text
Text

Text
Text
Text
Text

Text
Text
Text
Text

"

Note that there is a new line between each text block. Also note that the final text block itself has two new lines after it. Therefore when i do

string[] strArray = Regex.Split(content, "\r\n");

This works well as it searches for a carriage return pattern followed by a new line. HOWEVER, for the very last record in the array, it creates only "" (empty string), because it splits into the very last extra string.

, "\ r\n", \r ON\n.

?

+3
3

"\r\nText\r\nText\r\n\r\n",

not

"\\NTEXT\\NTEXT\\N\N"

, , , .. "\ r\n", . ( - , \r " ", \n " " ).

,

string[] strArray = Regex.Split(content, "(\r\n)*");
0

- ?

var strArray = content.Split(new[] { "\r\n" },
    StringSplitOptions.RemoveEmptyEntries);
+5

Regex, \r\n, \n,

"\r\n(?!\n)"

? , , "\ r\n\n", ...

+1
source

Source: https://habr.com/ru/post/1735516/


All Articles