PCRE2Project / pcre2

PCRE2 development is now based here.
Other
919 stars 191 forks source link

Add Python-style \1 backreferences in pcre2_substitute() #473

Closed NWilson closed 2 months ago

NWilson commented 2 months ago

Previously, using \1 inside a pcre2_substitute string would cause a bad-replacement error.

Now, we support this syntax in the same way as Python, to mean the same as ${1}.

PhilipHazel commented 2 months ago

I see that there is a compiler warning which has prevented the Dev action from completing. Otherwise, I think this is uncontentious.

carenas commented 2 months ago

Since you are also a new contributor might not be aware that since this code was originally managed with subversion there are really no merges, so if you want to have a coherent commit message it will be better if you squash your changes (specially considering that the second commit is just a "fixup").

NWilson commented 2 months ago

Since you are also a new contributor might not be aware that since this code was originally managed with subversion there are really no merges, so if you want to have a coherent commit message it will be better if you squash your changes (specially considering that the second commit is just a "fixup").

Thanks that's helpful, I've rebased & squashed the commits. I was assuming that the PR would be merged by squash merge, with the commit comment taken from the title of the PR.

PhilipHazel commented 2 months ago

I had a worry that introducing this would be backwards incompatible because of the octal ambiguity, but then I remembered that octal in substitution strings is broken in the current release, so nobody out there can actually be using it. I note that currently it has the Perl ambiguity behaviour but presumably when the #470 is applied that will apply here too so that the behaviour in patterns and in substitutions is the same.I will merge this and then document it.

NWilson commented 2 months ago

I remembered that octal in substitution strings is broken in the current release, so nobody out there can actually be using it. I note that currently it has the Perl ambiguity behaviour but presumably when the https://github.com/PCRE2Project/pcre2/pull/470 is applied that will apply here too so that the behaviour in patterns and in substitutions is the same.

Agreed on both. There is no regression. And, I intend for the other PR to apply the Perl/Python ambiguity option to both patterns and replacements.