[Interest] QRegularExpression for replace

Scott Bloom scott at towel42.com
Sun Dec 4 08:02:24 CET 2022

That is basically what I did for the non problematic replacements.  The ones that not only need the captured text, but also need the rest of the text I didn't bother implementing


-----Original Message-----
From: Interest <interest-bounces at qt-project.org> On Behalf Of Thiago Macieira
Sent: Thursday, December 1, 2022 8:14 PM
To: interest at qt-project.org
Subject: Re: [Interest] QRegularExpression for replace

On Thursday, 1 December 2022 11:43:39 PST Scott Bloom wrote:
> Im looking for a way using QRE to do something like the following
> auto regEx = QRegularExpression( "(?<name>.*)" ); if ( regEx.match( 
> string ) )
>                 auto newString = regEx.replace( string, "${name}" );

This requires having a parser for the replacer too, which is not something we currently have.

The QRegularExpressionMatch result gives you all the regions in the string where captures were found, so you can  do this yourself if you know your captures.

Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering

Interest mailing list
Interest at qt-project.org

More information about the Interest mailing list