-
Notifications
You must be signed in to change notification settings - Fork 7
re_replace: backslash escaping changed #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@kamahen, was this change intended? I found some compatibility page at https://www.regular-expressions.info/replacebackref.html, which claims that \1-\9 is supported by most major languages (doesn't talk about \0). It is deprecated in Perl. |
library(pcre) does not use PCRE2's replacement API; it continues to do things in the same way as the old code that used PCRE1. The handling of \1-\9 is in Prolog code, in particular Line 608 in 6200023
I did make some changes in how replacements are handled - in particular, there were some bugs that I fixed (e.g., see Issue #9 and Issue #5). There was also a problem with "\" escaping ... this seems to be the relevant commit: 49e811c ... it's possible that I don't have enough test cases, so I'll put together a PR that adds something like what @spl has pointed out and - if it indicates a bug rather than a bug that's been fixed - I'll come up with a fix. But it could take me a few days to do this (I'm preoccupied with some other things) -- I hope that's OK. |
No problem. The last example I wrote works before and after, so I've already changed our code to use that. Thanks! |
In 6c70176...fe4775d (which I derived from SWI-Prolog/swipl-devel@4c14056), something change in how
re_replace
worked. I think it has to do with the backslash escaping.Before the above commit range, this worked:
After the above commit range,
Out
changed:In order to get back to the first
Out
, I can add\\
:Fortunately, I can also use
$0
instead of\0
, which works both before and after the above commit range:The text was updated successfully, but these errors were encountered: