(If there's a ticketing system I've somehow missed please let me know and
I'll file this there)


Bug: irregex-replace/all only replaces first match when negative
lookbehinds are involved

example:

the following regexp should replace any letter a preceded by x, y, or z

problematic code

(irregex-replace/all "(?<=[xyz])a"     "xa ya za"  "-")
; or
(irregex-replace/all '(: (look-behind (or "x" "y" "z")) "a")   "xa ya za"  "-")

should return "x- y- z-"
BUT actually returns "x- ya za"

Note. I'm not 100% confident in my SRE syntax but I am reasonably confident
the PCRE is correct.

PCRE csi output

#;29> (irregex-replace/all "(?<=[xyz])a"     "xa ya za"  "-")
"x- ya za"

SRE csi output

(irregex-replace/all '(: (look-behind (or "x" "y" "z")) "a")   "xa ya za"  "-")
"x- ya za"

Sanity check with Ruby’s REPL:

irb(main):002:0> "xa ya za".gsub(/(?<=[xyz])a/, "-")
=> "x- y- z-"



- Kay Rhodes
https://masukomi.org

Reply via email to