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
Solved

Regular expression required to validate a FileUpload path.

Posted on 2006-11-23
9
348 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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