[Development] QTBUG-23489: Implement the new regular expression classes using PCRE

Thiago Macieira thiago at kde.org
Sat Feb 25 10:48:02 CET 2012

On sábado, 25 de fevereiro de 2012 02.48.11, Giuseppe D'Angelo wrote:
> 1) add the operator QRegularExpression() const to QRegExp and remove
> the QString overloads taking a QRegExp:
> Drawbacks:
> * possible subtle bugs introduced by the different QRegExp and
> QRegularExpression behaviours/quirks/syntax support/etc.

This would be my preferred way, but if a slight behaviour change exists, then 
these two operations would produce different results:

	int idx = string.indexOf(rx);
	int idx = rx.indexIn(string);

The whole reason why we kept QRegExp in the first place was so that we wouldn't 
introduce those subtle issues (and for qmake). So, aside from qmake, if  we 
managed to convert the QRegExp expressions to PCRE, we could also get rid of 
the QRegExp engine altogether.

In which case we could even keep QRegExp as a deprecated class for these 

> * decide what to do with the overloads taking a non-const-ref QRegExp
> (used to extract captures, matched length, etc.)
> * ... fix QRegExp. Right now it is bugged, and things like
>     QRegExp re("...");
>     /* do something like string.indexOf(re),
>     which does not actually *use* re,
>     but it just converts it to QRegularExpression */
>     re.matchedLength();

Just so people understand, this crashes:

	QRegExp re;

> will crash (I have a patch that I think fixes it, but I don't know
> what it *exactly* does... who's the QRegExp maintainer?)

I guess that's now you.

> 2) Go with something like
>     template <typename RE> inline QT_DEPRECATED QString &replace(const
> RE &rx, const QString &after, typename RE::isQRegExp * = 0)
>     {
>         // inline implementation, or call a method exported by the
> QRegExp library
>     }
> Pro
>   * Should be 100% compatible
> Drawbacks
>   * str.replace(re, "foo") doesn't compile any more -- it's not found
> during template lookup, since no overload is found taking (QRegExp,
> const char[3]). That is, more template black magic is required for
> each and every parameter but the first, to enable implicit
> conversions. Help! :)
> Comments?

How difficult is it to convert the QRegExp expressions to PCRE?

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120225/f91ce783/attachment.sig>

More information about the Development mailing list