firasdib / Regex101

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

PCRE2: substitution given the expression "$\K" works when it shouldn't. #2073

Closed PS1Online closed 1 year ago

PS1Online commented 1 year ago

Using perl this works in the substitution:

perl -0777spe 's/\A.*?^text1.*?\K$/ text8/gms' -- file.txt

and this not:

perl -0777spe 's/\A.*?^text1.*?$\K/ text8/gms' -- file.txt

On the other hand, both ways work on the site, when it shouldn't be like this:

https://regex101.com/r/XFMo1F/1

firasdib commented 1 year ago

Perl is not PCRE. From my tests, this looks to be the intended behavior in PCRE. If you believe it to be a bug with the library, I suggest you open an issue in the official PCRE repository so it can be fixed there.