Solved

Regular expression required to validate a FileUpload path.

Posted on 2006-11-23
9
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

726 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