=== Program that splits on lines with Regex (C#) ===
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string value = "cat\r\ndog\r\nanimal\r\nperson";
//
// Split the string on line breaks.
// ... The return value from Split is a string[] array.
//
string[] lines = Regex.Split(value, "\r\n");
foreach (string line in lines)
{
Console.WriteLine(line);
}
}
}
=== Output of the program ===
cat
dog
animal
person
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string value = "cat\r\ndog\r\nanimal\r\nperson";
//
// Split the string on line breaks.
// ... The return value from Split is a string[] array.
//
string[] lines = Regex.Split(value, "\r\n");
foreach (string line in lines)
{
Console.WriteLine(line);
}
}
}
=== Output of the program ===
cat
dog
animal
person
Labels: === Program that splits on lines with Regex (C#) ===
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home