Case is not preserved if the matched term is not a whole word:
(ppcre:regex-replace-all "(?i)foo" "Fooz" "roo" :preserve-case t)
"rooz"
T
It works with whole words though:
> (ppcre:regex-replace-all "(?i)foo" "Foo z" "roo" :preserve-case t)
"Roo z"
T
This is by design, since string-case-modifier has this:
(if (or (<= to from)
(and (< start from)
(alphanumericp (char str (1- from)))
(alphanumericp (char str from)))
(and (< to end)
(alphanumericp (char str to))
(alphanumericp (char str (1- to)))))
;; if it's a zero-length string or if words extend beyond FROM
;; or TO we return NIL, i.e. #'IDENTITY
nil
My feature request is to add an option to allow preserving case even for words that extend beyond the boundaries.
What do you think?
Case is not preserved if the matched term is not a whole word:
It works with whole words though:
This is by design, since
string-case-modifierhas this:My feature request is to add an option to allow preserving case even for words that extend beyond the boundaries.
What do you think?