Results 1 to 3 of 3

Thread: QRegExp validate windows file path

  1. #1
    Join Date
    Jan 2010
    Posts
    6
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QRegExp validate windows file path

    Hi all,

    I'm trying to use QRegExp to validate a windows file path and I tried a lot of different regular expressions and I cant get it to work, this expression works in a lot of test tools but not in qt:

    QRegExp uri("([a-z A-Z]:\\[^/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^/:\*\?<>\|]+\.\w{2,6})");

    Does someone has a working regexp or can you see whats the problem with the above.

    Thanks for your help

    /Nick

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QRegExp validate windows file path

    RegExp's are not really my piece of cake... But Qt works always with '/' as a separator, so maybe you have to change your backslashes into slashes?
    .

  3. #3
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QRegExp validate windows file path

    QRegExp is made to work with user input regular expressions. If you want to match a backslash, you have to use four in your code; two for the escape backslash and two for the actual backslash. That also goes for other escaped characters (e.g. \\b, \\s).

    Review the QRegExp docs for more detailed info.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  4. The following user says thank you to franz for this useful post:

    niol1000 (2nd February 2010)

Similar Threads

  1. How to validate QSQLITE file?
    By rakkar in forum Newbie
    Replies: 1
    Last Post: 24th September 2009, 01:05
  2. Can I use QRegExp to remove the extension of a file?
    By ricardo in forum Qt Programming
    Replies: 3
    Last Post: 20th May 2009, 13:54
  3. Using QRegExp For File Filtering
    By QbelcorT in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2009, 09:02
  4. how does Qt knows Qt-dll path in windows
    By babu198649 in forum General Programming
    Replies: 7
    Last Post: 21st November 2008, 10:39
  5. MinGW Windows Library Search Path
    By zztop in forum Qt Programming
    Replies: 4
    Last Post: 26th March 2006, 15:18

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
  •  
Qt is a trademark of The Qt Company.