firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.21k stars 198 forks source link

QRegExp Flavor #2147

Open brightghost opened 9 months ago

brightghost commented 9 months ago

Flavor Request

Reopening https://github.com/firasdib/Regex101/issues/513 . The context I'm encountering this in is KDE's KRename utility, which is likely a common use-case for people who don't already have a deep familiarity with regex.

KRename seems to still be using the older QRegExp library. QRegExp generally follows PCRE conventions, but the differences are well-summarized in the docs.

The distinction that tripped me up is the capture group substitution, which uses the \1 syntax rather than $1. This is perhaps a bit complicated because technically QRegExp does not implement substitution strings, though it does define backreferences using the \1 format, which suggests using the same in substitution strings, which KRename, at least, follows.

The new QRegularExpression library is apparently PCRE-compatible, though it seems the situation is the same with substitution strings implicitly using \1 syntax, so that might be another issue regarding assumptions about PCRE substitution string conventions.

working-name commented 9 months ago

Hi @brightghost didn't read the docs but to tackle just your \1 for now - the older PCRE version supports that (not PCRE2).