Solved

Regular expression required to validate a FileUpload path.

Posted on 2006-11-23
9
342 Views
Last Modified: 2007-01-08
Why is the following validation expression for my RegularExpressionValidator failing on my jpg upload?

     ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.jpg|.jpeg|.gif|.bmp|.png)$"

See:
       http://msdn2.microsoft.com/en-us/library/aa479405.aspx.

I changed the example shown and modified it to allow on image files.
It may be because I have incorrectly interpreted when converting expression to a single line expression from:

   ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))
    +(.mp3|.MP3|.mpeg|.MPEG|.m3u|.M3U)$"



Any help appreciated.

0
Comment
Question by:smacca
9 Comments
 
LVL 19

Expert Comment

by:DreamMaster
ID: 18003474
Hi smacca,

Easiest way to find out...change the example into one line...does it still work? Then you did something else wrong, doesn't work? (which would be my first guess) then the + is probably the one causing you a headache..

Regards,
Max.
0
 
LVL 12

Expert Comment

by:sandip132
ID: 18005606
try this:

string fRegex = "^.+\.((jpg)|(gif)|(jpeg))$";
0
 
LVL 6

Expert Comment

by:badalpatel
ID: 18005810
try this one

ValidationExpression="^([a-zA-Z]\:|\\)\\([^\\]+\\)*[^\/:*?'<;>;|]+\.(jpg|jpeg|gif|bmp|png)(l)?$"
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:smacca
ID: 18014500
The following validation expression is not working:

ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.jpeg|.JPG|.JPEG)$"

0
 
LVL 6

Accepted Solution

by:
badalpatel earned 500 total points
ID: 18018038
have u tried my expression??


ValidationExpression="^([a-zA-Z]\:|\\)\\([^\\]+\\)*[^\/:*?'<;>;|]+\.(jpg|jpeg|gif|bmp|png)(l)?$"
0
 

Author Comment

by:smacca
ID: 18033159
Can you tell me what is wrong with the first expression.
It is the one provided by Microsoft?
0
 
LVL 6

Expert Comment

by:badalpatel
ID: 18273113
whats mod yaar..
my expression is completely right here..
i should be awarded point
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now