howto use c# regular expression validator to exclude file types

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

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

    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" <boah123@hotmail.com> wrote in message
    news:bgbf5g$8o1$1@news4.tilbu1.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 Guest

  2. Similar Questions and Discussions

    1. Regular expression bug?
      All of CF's RE functions act in a weird way, contrary to the documentation (both CF's own, and the underlying Java Regex docs). The special...
    2. extend Regular expression validator control
      Hi all, I would like to extend Regular expression validator control to read from a config file, the custom expressions to validate. basically...
    3. help on regular expression
      Hi, I need some help on regular expression... i have following in variable $total_count $total_count = "##I USBP 000001 10:38:09(000)...
    4. regular expression help..
      On Thu, 28 Aug 2003 15:50:49 +0200 "point" <point@caanNOSPAMproduction.com> wrote: Don't cross post, it's considered bad form. /^-+$/ ...
    5. [PHP] REGULAR EXPRESSION HELP
      John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:...
  3. #2

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

    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" <bgvallelunga@starpower.net> schreef in bericht
    news:eLuKYN6VDHA.2100@TK2MSFTNGP11.phx.gbl...
    > 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" <boah123@hotmail.com> wrote in message
    > news:bgbf5g$8o1$1@news4.tilbu1.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 Guest

  4. #3

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

    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" <boah123@hotmail.com> wrote in message
    news:bgc2i8$d8l$1@news2.tilbu1.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" <bgvallelunga@starpower.net> schreef in bericht
    > news:eLuKYN6VDHA.2100@TK2MSFTNGP11.phx.gbl...
    > > 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" <boah123@hotmail.com> wrote in message
    > > news:bgbf5g$8o1$1@news4.tilbu1.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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139