Link to home
Start Free TrialLog in
Avatar of smacca
smaccaFlag for Australia

asked on

Regular expression required to validate a FileUpload path.

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.

Avatar of DreamMaster
DreamMaster

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.
try this:

string fRegex = "^.+\.((jpg)|(gif)|(jpeg))$";
try this one

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

ASKER

The following validation expression is not working:

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

ASKER CERTIFIED SOLUTION
Avatar of badalpatel
badalpatel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smacca

ASKER

Can you tell me what is wrong with the first expression.
It is the one provided by Microsoft?
whats mod yaar..
my expression is completely right here..
i should be awarded point