Results 1 to 3 of 3

Thread: QRegExp validator

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

    Default QRegExp validator

    Hi, i'd like to create a QRegExp to validate my input, i need a regExp that allows the user to insert digit, letters and space, but the first chat can't be a space.
    I created this one:
    "[A-Za-z0-9\\s]+"
    but as you can see i can insert a space and the validator is true, and it's not good...what should i do?
    thx

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

    Default Re: QRegExp validator

    something like taht works:
    "^[A-Za-z0-9]+[A-Za-z0-9\\s]+"
    is there a better way?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QRegExp validator

    "[A-Za-z\\d][A-Za-z\\d\\s]*" should do the trick.

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

    mattia (28th November 2007)

Similar Threads

  1. QRegExp Help
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2007, 00:13
  2. QRegExp progblem
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2006, 12:12
  3. QRegExp?
    By Marco812 in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2006, 08:31
  4. need help for my QRegExp
    By patcito in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 16:29
  5. Trouble parsing using simple QRegExp
    By johnny_sparx in forum Qt Programming
    Replies: 4
    Last Post: 24th February 2006, 00:42

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.