Re: howto use c# regular expression validator to exclude file types

B

Brian Vallelunga

I'm not great at regular expressions, but something like this should work:

(.*\.jpg)|(.*\.jpeg)|(.*\.png)|(.*\.gif)

That should do the trick. If you just want jpg files, try:
(.*\.jpg)|(.*\.jpeg)

Each section within ( ) means, any number of characters, followed by a . and
then the extension.

Brian
 
A

Arjen

Hmm, the extension is now case sensitive.
Which means that JPG is not working.

I can do this:
(.*\.jpg)|(.*\.JPG)

But is there also a way to check the upper-case on the same moment... I mean
is there a special character for that?

Thanks!
 
B

Brian Vallelunga

Hmm... theoretically there is, but I can't get it to work. Read here (if you
have msdn installed):

help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpgenref/html/cpconregularexpres
sionoptions.htm

It talks about putting in an option inline, but it wouldn't work for me.
Also, you should probably change all of those "*" to "+" in my previous
example.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top