allow replacement with capture groups even if not all are participating in the match #7
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently when trying to use string replacement like in:
https://regex101.com/r/UFsDMr/1
so having regular expression:
and test string:
and replacement:
the following runtime error is thrown:
as capture group not participating in the match are still tried to be accessed, but they should be allowed and if their value is not set should not produce any replacement value (= they should be an empty string).
This PR https://github.com/Elara6331/pcre/pull/3/changes fixes that incorrect behaviour, so that the above regular expression replacement results in expected:
string.
Inlining the code from the above PR from GH: