Results 1 to 4 of 4

Thread: qregexp to check string

  1. #1
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qregexp to check string

    Hello, i have to validate this string "http://username:password@url:port" with a QRegExp.
    I want that my regExp control if the string start with "http://" and contain 3 ":" occurrences and 1 "@" occurrences.

    I get some problem to build the regExp, i started in this way:

    "^[http://]+[:]{3}+[@]{1}" but it does not work...any hint?
    Last edited by jpn; 19th February 2008 at 09:39. Reason: Disabled smilies

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qregexp to check string

    How about using QUrl.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qregexp to check string

    Or using simple QString functions instead thinking about the correct regexp for hours.

  4. #4
    Join Date
    Oct 2006
    Posts
    12
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qregexp to check string

    I will (probably) not help you with this reply, but using regex is better than using QString functions - you can build regex lineedit or some other control - checking for correct input of another string format is just regex away, while with QString parsing you would need to modify code each time - bad, bad, bad... there are nice examples on msdn, and there is regex building support in visual studio find dialog - maybe that will help you.

Similar Threads

  1. QRegExp Help
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2007, 01:13
  2. Reading from sockets in a multithreaded program
    By KoosKoets in forum Qt Programming
    Replies: 9
    Last Post: 4th April 2007, 21:43
  3. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 15:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.