Results 1 to 6 of 6

Thread: requesting code to validate filename with regular expressions

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    requesting code to validate filename with regular expressions

    it's pretty simple if you know regular expressions, so please help me out
    I want an expression to validate if a filename is correct or not. The filename should not contain any of these characters: \ / : * ? " < > |

    I would really appreciate this I dont know how to work with regular expressions myself. I know I can do it without regex but still would be better this way
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Best place in the world for RegEx's

    http://regexlib.com/Search.aspx?k=filename

    2nd one down looks good..

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    whoa cool, thank
    one q: that's the "matches" and "non-matches" thing? are those just examples?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by MrPolite
    one q: that's the "matches" and "non-matches" thing? are those just examples?
    Yes.

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    The matches and non-matches are the results of using testing the regex against whatever you put in the input field.

    It allows you test the RegEx for common things to be certain it does what is has been advertised to do, and also allows you to change the regex real-time and keep retesting it.

    Also be sure to test the RegEx with .Net and Javascript by selecting the appropriate radiobutton.

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    I just made this up off top of my head...

    "^[^\\<>|\""\?\*]+(\.[^\\<>|\""\?\*]{1,3})?$"

    Matches hello.txt but not hel\lo.txt.

    Haven't tested it further than that though.

    The above is a VB qualified string, I had to double up on the quote characters to make it work the real Regex string (in memory) should look like this...

    "^[^\\<>|\"\?\*]+(\.[^\\<>|\"\?\*]{1,3})?$"
    I don't live here any more.

Posting Permissions

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



Click Here to Expand Forum to Full Width