|
From: | masukomi |
Subject: | chicken.irregex bug with positive lookbehinds |
Date: | Thu, 9 Jul 2020 21:51:51 -0400 |
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-"
[Prev in Thread] | Current Thread | [Next in Thread] |