8000 re_replace can't handle same sub-pattern twice · Issue #9 · SWI-Prolog/packages-pcre · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

re_replace can't handle same sub-pattern twice #9

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

Closed
kamahen opened this issue Jan 27, 2022 · 1 comment
Closed

re_replace can't handle same sub-pattern twice #9

kamahen opened this issue Jan 27, 2022 · 1 comment

Comments

@kamahen
Copy link
Member
kamahen commented Jan 27, 2022
?- re_replace("(.)"/g, "[$1][$1]", "abcd", Y).
ERROR: Duplicate key: 1
ERROR: In:
ERROR:   [13] dict_pairs(_6438,_6440,[1-_6454,...])
ERROR:   [11] pcre:compile_replacement("[$1][$1]",r(["["|...],_6498)) at /usr/lib/swi-prolog/library/pcre.pl:398
ERROR:   [10] pcre:re_replace("(.)"/g,"[$1][$1]","abcd",_6540) at /usr/lib/swi-prolog/library/pcre.pl:321
ERROR:    [9] toplevel_call(user:user: ...) at /usr/lib/swi-prolog/boot/toplevel.pl:1135

This should work, e.g.:

$ python3.10
>>> import re
>>> re.sub(r'(.)', r'[\1\1]', 'abcd')
'[aa][bb][cc][dd]'
@kamahen
Copy link
Member Author
kamahen commented Jan 27, 2022

Duplicate of Issue #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0