Hello David, No problem. QRegularExpression is PCRE (perl-compatible reg ex) so you could use https://regex101.com with (php-pcre on the left) to check your patterns against a sample string, and even you get an explanation on the right what is done/matched. Not everything (as syntax) is supported in Qt, but most of the things are available.
Kind regards, Konstantin. On Mon, Dec 28, 2015 at 1:34 AM, <[email protected]> wrote: > Hi Nye, > > In fact, my regular expression was wrong. Yours works like a charm. I > appreciate your help. Thank you so much 😊 > > Regards > David > > Envoyé depuis Windows Mail > > *De :* Nye <[email protected]> > *Envoyé :* ‎lundi‎ ‎28‎ ‎décembre‎ ‎2015 ‎00‎:‎23 > *À :* [email protected] > *Cc :* [email protected] > > Hello, > Your regular expression is very strange. You have a character class with > two symbols and then you don't have a capture group? Maybe try this: > "(?<=\\s)c:\\s?(.*)$" > > Kind regards. > > On Mon, Dec 28, 2015 at 12:42 AM, <[email protected]> wrote: > >> I am currently trying to extract the following chain of character: >> >> This is a rectangle. Its height is 193, its width is 193 and the word >> number is 12. >> >> from the following line: >> >> ID: 1 x: 1232 y: 2208 w: 193 h: 390 wn: 12 ln: 13 c: This is a rectangle. >> Its height is 193, its width is 193 and the word number is 12 ! >> >> I have to do this using QRegularExpressions. Therefore, my code is as >> following: >> >> >> regularExpression.setPattern("[c:](?:\\s*)$"); >> QRegularExpressionMatch match = regularExpression.match("ID: 2 x: 845 >> y: 1633 w: 422 h: 491 wn: 78 ln: 12 c: qsdfgh"); >> if (match.hasMatch()) { >> QString id = match.captured(0); >> qDebug()<<"The annotation is:"<<id; >> return id; >> } >> return 0; >> >> >> However, it does not work at all and I do not understand why (maybe my >> regular expression is not correct).I am stuck in this problem from several >> days now. >> >> Could you help me please ? >> >> Best regards >> David >> >> >> _______________________________________________ >> Interest mailing list >> [email protected] >> http://lists.qt-project.org/mailman/listinfo/interest >> >> >
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
