Results 1 to 3 of 3

Thread: Regular Expression YYYY-MM-DD and YYYY MM DD

  1. #1
    Join Date
    Jul 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Regular Expression YYYY-MM-DD and YYYY MM DD

    hi, i am a beginner in C++ using Qt4, i need help in writting the regular expression to accept YYYY-MM-DD and YYYY MM DD date formats.

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Regular Expression YYYY-MM-DD and YYYY MM DD

    1. Did you try to find it? Here are some examples. You can modify them.
    2. I will assume you are trying to validate user input. If that is true, then take a look at QDateTimeEdit. It should this validation for you.
    Last edited by lyuts; 2nd July 2010 at 11:41. Reason: updated contents
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Jun 2019
    Posts
    2
    Qt products
    Qt5 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Windows Android Maemo/MeeGo

    Default Re: Regular Expression YYYY-MM-DD and YYYY MM DD

    Quote Originally Posted by lyuts View Post
    1. Did you try to find it? Here are some examples. You can modify them.
    2. I will assume you are trying to validate user input. If that is true, then take a look at QDateTimeEdit. It should this validation for you.

    The code below worked for this format, yyyy/MM/ dd i.e 2019/12/02

    QRegExp R_date("(19[0-9][0-9]|20[0-9][0-9]) /(0[1-9]|[12]{1,2})/(0[1-9]|[12][0-9]|3[01]{1,2})");
    QRegExpValidator *valida = new QRegExpValidator(R_date, this);
    ui->lineEdit->setValidator(valida);

Similar Threads

  1. Regular Expression for QDate [YYYY/MM/DD] format
    By bera82 in forum Qt Programming
    Replies: 6
    Last Post: 3rd August 2019, 10:40
  2. QDateEdit Init Value ' / /yyyy'
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2007, 13:26
  3. Replies: 7
    Last Post: 17th November 2007, 12:33
  4. Regular expression in QLineEdit?
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 1st October 2007, 11:58
  5. Find with Regular Expression?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2007, 15:44

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.