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

Discussion in 'ASP .Net' started by Brian Vallelunga, Jul 31, 2003.

  1. 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


    "Arjen" <> wrote in message
    news:bgbf5g$8o1$1.nb.home.nl...
    > Hello,
    >
    > Can you use the ASP.NET C# Regular Expression Validator to make sure
    > that a user can only upload filenames with extension *.jpg?
    >
    > If so, how?
    > Because I don't know how the expression should look like.
    >
    > Greetings en thanx in advance!
    >
    >
    Brian Vallelunga, Jul 31, 2003
    #1
    1. Advertising

  2. Brian Vallelunga

    Arjen Guest

    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!



    "Brian Vallelunga" <> schreef in bericht
    news:...
    > 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
    >
    >
    > "Arjen" <> wrote in message
    > news:bgbf5g$8o1$1.nb.home.nl...
    > > Hello,
    > >
    > > Can you use the ASP.NET C# Regular Expression Validator to make sure
    > > that a user can only upload filenames with extension *.jpg?
    > >
    > > If so, how?
    > > Because I don't know how the expression should look like.
    > >
    > > Greetings en thanx in advance!
    > >
    > >

    >
    >
    Arjen, Jul 31, 2003
    #2
    1. Advertising

  3. 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


    "Arjen" <> wrote in message
    news:bgc2i8$d8l$1.nb.home.nl...
    > 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!
    >
    >
    >
    > "Brian Vallelunga" <> schreef in bericht
    > news:...
    > > 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
    > >
    > >
    > > "Arjen" <> wrote in message
    > > news:bgbf5g$8o1$1.nb.home.nl...
    > > > Hello,
    > > >
    > > > Can you use the ASP.NET C# Regular Expression Validator to make sure
    > > > that a user can only upload filenames with extension *.jpg?
    > > >
    > > > If so, how?
    > > > Because I don't know how the expression should look like.
    > > >
    > > > Greetings en thanx in advance!
    > > >
    > > >

    > >
    > >

    >
    >
    Brian Vallelunga, Jul 31, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,267
  2. RJN
    Replies:
    2
    Views:
    19,943
    Frank
    Feb 25, 2005
  3. Replies:
    8
    Views:
    13,818
    John C. Bollinger
    Nov 10, 2005
  4. Replies:
    6
    Views:
    757
    Bengt Richter
    Nov 8, 2005
  5. Azalar ---
    Replies:
    6
    Views:
    193
    Robert Klemme
    Sep 8, 2008
Loading...

Share This Page