Hi,
I have modified the code a bit and its working
string[] lines = File.ReadAllLines("d:\\milind.txt");
Regex regex = new Regex(@"\d{8}_TRYN_YZ");
foreach (string line in lines)
{
Match match = regex.Match(line.Trim());
if (match.Success)
{
Console.WriteLine(line);
}
}
I have used following data in the file.
05/23/12 19:31:21: dsetup32\01234567_TRYN_YZ.txt
05/23/12 19:31:22: dsetup32\_TRYN_YZ.txt
05/23/12 19:31:23: dsetup32\01234567__YZ.txt
05/23/12 19:31:24: dsetup32\01234533_TRYN_YZ.txt
05/23/12 19:31:25: dsetup32\01234544_TRYN_YZ.txt
And it displayed result correctly as
05/23/12 19:31:21: dsetup32\01234567_TRYN_YZ.txt
05/23/12 19:31:24: dsetup32\01234533_TRYN_YZ.txt
05/23/12 19:31:25: dsetup32\01234544_TRYN_YZ.txt
Hope that helps.
Milind