[Interest] QRegularExpression for replace

Tony Rietwyk tony at rightsoft.com.au
Fri Dec 2 01:59:58 CET 2022


On 2/12/2022 6:43 am, 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}” );
>
> Using the standard set of regex subsitutions
>
> Is this something anyone is looking at? Or is there a solution outthere?
>
> Scott
>
Hi Scott,

I have no idea what 'the standard set of regex substitutions' are, but 
have you seen QString replace(const QRegularExpression &re, const 
QString &after) ?

It supports capturing groups in the after string as well.

Hope that helps,

Tony

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221202/4656d299/attachment.htm>


More information about the Interest mailing list