?
Solved

Regular expression required to validate a FileUpload path.

Posted on 2006-11-23
9
Medium Priority
?
352 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
Industry Leaders: 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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