Re: Regular Expression to validate file extension
From: Chris Kennedy (nospam_at_nospam.co.uk)
Date: 06/19/04
- Next message: Martin: "Re: SQL Newsgroup"
- Previous message: Daniel Walzenbach: "Re: How to set controls in a DataGrid's ItemDateBound without a costly conversion?"
- In reply to: bloomfield: "Re: Regular Expression to validate file extension"
- Next in thread: Chris Kennedy: "Re: Regular Expression to validate file extension"
- Reply: Chris Kennedy: "Re: Regular Expression to validate file extension"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 19 Jun 2004 14:17:25 +0100
It tried putting this in the validation expression of my regular expression
validator, got it to validate a textbox with qwerty.jpg as the text value
and it didn't work. Any ideas? Regards, Chris.
"bloomfield" <bloomfield@as.ro> wrote in message
news:#KRWWfUVEHA.712@TK2MSFTNGP11.phx.gbl...
> Here there are some clues
>
> string checkFileRegex = @"^.+\.((jpg)|(gif)|(jpeg))$";
>
> string[] testData = new string[]
> {
> @"D:\My\download\test1.gif",
> @"D:\My\download\test2.cmd",
> "TeSt3.jPg",
> "test4.opp",
> "test5.JPG",
> "test6.gIn",
> "test7.again.jpeg",
> "nothing"
> };
>
> foreach(string test in testData)
> {
> if( Regex.IsMatch(test, checkFileRegex, RegexOptions.Multiline |
> RegexOptions.IgnoreCase ))
> {
> System.Diagnostics.Debug.WriteLine(string.Format("{0} OK", test));
> }
> else
> {
> System.Diagnostics.Debug.WriteLine(string.Format("{0} NOT OK", test));
> }
> }
>
> Hope this helps
>
> --
> ____________________
> www.bloomfield.as.ro
>
> Chris Kennedy wrote:
> > Does anyone know a regular expression that will validate the file
extension
> > but also allow multiple file extensions if necessary. It also needs to
be
> > case insensitive. Basically, what I want is to validate a file input box
to
> > check if the extension is the correct type, i.e. .doc for a Word
Document
> > etc. Also I would like to check multiple file types, for instance allow
a
> > gif or a jpeg or a jpg.
> >
> > Regards, Chris.
> >
> >
- Next message: Martin: "Re: SQL Newsgroup"
- Previous message: Daniel Walzenbach: "Re: How to set controls in a DataGrid's ItemDateBound without a costly conversion?"
- In reply to: bloomfield: "Re: Regular Expression to validate file extension"
- Next in thread: Chris Kennedy: "Re: Regular Expression to validate file extension"
- Reply: Chris Kennedy: "Re: Regular Expression to validate file extension"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|