0

I'm trying to split a var on "\r\n"

Here is my code:

          var tempRow = row.InnerText.ToString();

                //   "\r\n  08:05 PM\r\n  963\r\n  Chicago Cubs K. Hendricks -R\r\n  \r\n  \r\n  \r\n   \r\n  -1½\r\n  +130\r\n  \t\r\n......"

                string[] tempItem = Regex.Split(tempRow.ToString(), @"\\r\\n");

But my tempItem[] doesn't split and has 1 element.

Trey Balut
  • 1,355
  • 3
  • 19
  • 39

1 Answers1

2

If you're using @ (Verbatim string literal) before the string, you do not need to escape backslashes:

string[] tempItem = Regex.Split(tempRow.ToString(), @"\r\n");

For more information on Verbatim Strings, I highly suggest checking out this link: What's the @ in front of a string in C#?

Blue
  • 22,608
  • 7
  • 62
  • 92