akhil
akhil

Reputation: 1212

Regex returning null while searching for a string

I am wroking on a ASP.NET console application using C# that is trying to read some files from a website by logging in and then writing the files on local drive.

I have following Regex which searches for some string in a text file -

var fileNames = (from Match m in Regex.Matches(pageSource, @"[0-9]+_+[A-Za-z]+_+[0-9]+-+[0-9]+-+[0-9]+(_+[0-9]+)?\.+(acc|zip|app|xml|def|enr|exm|fpr|pnd|trm)")
                        select new { m.Value }).ToList();

This code was working perfectly with my web application doing the same task. But when I m using it in my console application, the filenames.count is 0.

What possibly could be the problem while this code still works with my web application?

Thanks in advance :)

Upvotes: 0

Views: 95

Answers (1)

akhil
akhil

Reputation: 1212

var fileNames = (from Match m in Regex.Matches(pageSource, @"[0-9]+_+[A-Za-z]+_+[0-9]+-+[0-9]+-+[0-9]+(_+[0-9]+)?\.+(acc|zip|app|xml|def|enr|exm|fpr|pnd|trm)")                         select m.Value).ToList(); 

That worked for me...

I removed

select new { m.Value }).ToList();

Thanks for replying and helping guys :)

Upvotes: 1

Related Questions