I have solved this:added a positive look ahead to the expression.(?=. ..)
string[] lines = System.Text.Reg ularExpressions .Regex.Split(ke ep, @"(?=\s\s\s\d\d \/\d\d\/\d\d\s\d\d\:\d\ d\s\s\w\w\d\d\d \d\d\d)");
foreach (string line in lines)
{ sw.WriteLine(li ne); }
User Profile
Collapse
-
Split line based on specific pattern using Regex
i need to split lines in text file based on a specific pattern.The pattern is " 01/12/12 00:39 AT400003".
The source file looks like:
AT400003 2012-12-01 00:36:03.000 abcdefghij 01/12/12 00:39 AT400003 abcdefjhij 01/12/12 01:39 AT400003 abcdefghij 01/12/12 00:39 AT400003 abcdefjhij
I need the output file to look like:
AT400003 2012-12-01 00:36:03.000 abcdefghij...
No activity results to display
Show More
Leave a comment: