Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QRegExp not found
Forum Updated to NodeBB v4.3 + New Features

QRegExp not found

Scheduled Pinned Locked Moved Solved General and Desktop
qregexp
3 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cfdev
    wrote on 9 Dec 2015, 16:57 last edited by
    #1

    Hi all,
    I try to use QRegExp to find and replace text with this code:

        QString text = "FC<date:yyMM><index>";
    	QRegExp expDate( "<date:(.*?)>" ); 
    	pos = expDate.indexIn( text );
    	if (pos > -1) {
    		qDebug()<< "database::checkCodeExp" << expDate.cap(1) << " " <<  expDate.cap(2);
    		text.replace(expDate,"DATE");
    	}else{
    		qDebug()<< "database::checkCodeExp notFound" << text << " regExp: "<< expDate.pattern();
    	}
    

    This expression "date:(.*?)" works with the tester php https://regex101.com/
    What am I doing wrong ?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 9 Dec 2015, 17:13 last edited by
      #2

      @cfdev said:
      Isn't (.*?) the same as (.*)? It looks that way to me. If you're using Qt5 do consider using the replacement(s) for QRegExp - QRegularExpression which is perl compatible.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cfdev
        wrote on 10 Dec 2015, 08:34 last edited by cfdev 12 Oct 2015, 08:40
        #3

        not the same (.*?) and (.*) I tested on QT4 and QT5

        Ok I found the solution with this regular expression:

        QRegExp regex("\\<date(:(.*))?\\>");
        
        1 Reply Last reply
        0

        3/3

        10 Dec 2015, 08:34

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved