Professional Web Applications Themes

howto use c# regular expression validator to exclude file types - ASP.NET General

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" <boah123hotmail.com> wrote in message news:bgbf5g$8o1$1news4.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 ...

  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" <boah123hotmail.com> wrote in message
    news:bgbf5g$8o1$1news4.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. #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" <bgvallelungastarpower.net> schreef in bericht
    news:eLuKYN6VDHA.2100TK2MSFTNGP11.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" <boah123hotmail.com> wrote in message
    > news:bgbf5g$8o1$1news4.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

  3. #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" <boah123hotmail.com> wrote in message
    news:bgc2i8$d8l$1news2.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" <bgvallelungastarpower.net> schreef in bericht
    > news:eLuKYN6VDHA.2100TK2MSFTNGP11.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" <boah123hotmail.com> wrote in message
    > > news:bgbf5g$8o1$1news4.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

Similar Threads

  1. Regular expression help
    By John in forum PERL Beginners
    Replies: 20
    Last Post: July 21st, 11:38 PM
  2. Regular expression bug?
    By twillerror in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: April 14th, 04:37 PM
  3. extend Regular expression validator control
    By shiv in forum ASP.NET Building Controls
    Replies: 1
    Last Post: August 12th, 01:30 AM
  4. Regular Expression Help please
    By Max Adams in forum PERL Miscellaneous
    Replies: 1
    Last Post: August 29th, 11:13 AM
  5. [PHP] REGULAR EXPRESSION HELP
    By John W. Holmes in forum PHP Development
    Replies: 3
    Last Post: July 14th, 01:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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