Results 1 to 7 of 7

Thread: QRegExp: Last sign has to be a number

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2016
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QRegExp: Last sign has to be a number

    Hello,

    i need a regular expression that ensures that the last sign in a QString is a digit and i tried the following code:


    Qt Code:
    1. QRegExp rx ("[0-9]$");
    2.  
    3. cout << rx.exactMatch("123") << endl;
    To copy to clipboard, switch view to plain text mode 

    i always get false as result, but i don't understand why?

    Can anybody tell me what i'm doing wrong?

    Thank you very much!

  2. #2
    Join Date
    Jan 2006
    Posts
    33
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: QRegExp: Last sign has to be a number

    Can't test but I think this should work:

    Qt Code:
    1. QRegExp rx (".*[0-9]$");
    To copy to clipboard, switch view to plain text mode 


    Your regexp should match this:
    Qt Code:
    1. cout << rx.exactMatch("3") << endl;
    To copy to clipboard, switch view to plain text mode 
    Does this match?
    If so, [0-9]$ machtes one and only one digit (exactMatch)
    [0-9] can be written as \d as well, just follow the link to QRegExp
    Last edited by Moppel; 19th January 2016 at 14:48.

Similar Threads

  1. QTableView replace row number with sign
    By Hostel in forum Qt Programming
    Replies: 6
    Last Post: 22nd May 2013, 21:39
  2. Replies: 1
    Last Post: 5th March 2012, 06:34
  3. how to sign my .msi file
    By athulms in forum Newbie
    Replies: 4
    Last Post: 28th September 2011, 07:10
  4. How to free sign my app ?
    By Sparkle24 in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 21st August 2011, 23:25

Tags for this Thread

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.