Re: Regular Expressions: find_replace_limit doesn't make all replacements
- Posted by ghaberek (admin) Feb 28, 2022
- 1166 views
Not sure I can be that much help here, but I suspect it is length 1 rather than spaces vs. tabs:
(The second shot works because you've got rid of all the length 1 previous substitutions, and that would still be true even if they were originally back-to-back)
As above, no expert here, but the code you are looking for might be in https://github.com/OpenEuphoria/euphoria/blob/99dff754918b9f66267b631d9c0be1d63c256d87/source/be_pcre.c right at the end,
start_from = ovector[rc] + rep_s->length;
might perhaps be missing a -1 [and don't blame me if that goes into an infinite loop/make sure you test with a trailing space on the substitution]
Thanks for finding this Pete. In my testing I had also determined this seemed related to the length-one capture groups being skipped due to an off-by-one error. I think you're correct about that line being the culprit here. I will do some more testing and get this resolved. (I really need to get our tickets moved to GitHub.)
-Greg