chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

chicken.irregex bug with positive lookbehinds


From: masukomi
Subject: chicken.irregex bug with positive lookbehinds
Date: Thu, 9 Jul 2020 21:51:51 -0400

(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-"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]