hi,
i'm a new bie to regular expressions..
i'm trying to see if a string ends with teh below
pattern \filename.xls or \filename.xlsx...

I've used the @"\\[\w|\W]+\.xls" pattern but's it's
matching hte below string
d:\sample\.xls....

can someone help me out with teh correct pattern

Re: regex help by Jerod

Jerod
Mon Sep 17 06:25:12 PDT 2007

On Sep 17, 6:32 am, AVL <A...@discussions.microsoft.com> wrote:
> hi,
> i'm a new bie to regular expressions..
> i'm trying to see if a string ends with teh below
> pattern \filename.xls or \filename.xlsx...
>
> I've used the @"\\[\w|\W]+\.xls" pattern but's it's
> matching hte below string
> d:\sample\.xls....
>
> can someone help me out with teh correct pattern

You could try @"\\[\w|\W]+\.xls$" if it is at the end of the string.
You could also use the System.IO.FileInfo class...

FileInfo fInfo = new FileInfo(@"\My Documents\Filename.xls");
if(fInfo.Extension.ToLower() == "xls")
{
...
}

Jerod


Re: regex help by Jerod

Jerod
Mon Sep 17 06:32:52 PDT 2007

On Sep 17, 7:25 am, Jerod Houghtelling <houghtell...@gmail.com> wrote:
> On Sep 17, 6:32 am, AVL <A...@discussions.microsoft.com> wrote:
>
> > hi,
> > i'm a new bie to regular expressions..
> > i'm trying to see if a string ends with teh below
> > pattern \filename.xls or \filename.xlsx...
>
> > I've used the @"\\[\w|\W]+\.xls" pattern but's it's
> > matching hte below string
> > d:\sample\.xls....
>
> > can someone help me out with teh correct pattern
>
> You could try @"\\[\w|\W]+\.xls$" if it is at the end of the string.
> You could also use the System.IO.FileInfo class...
>
> FileInfo fInfo = new FileInfo(@"\My Documents\Filename.xls");
> if(fInfo.Extension.ToLower() == "xls")
> {
> ...
>
> }
>
> Jerod

Sorry didn't entirely read your question correctly. You might want to
try @"\\[\w}\W]+\.xls[?x]" or @"\\[\w}\W]+\.xls[?x]$" depending if you
are reading a single line or multiple lines at a time.

Jerod