Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow :preserve-case on partial word match #51

Open
Ambrevar opened this issue Sep 7, 2022 · 0 comments
Open

Allow :preserve-case on partial word match #51

Ambrevar opened this issue Sep 7, 2022 · 0 comments

Comments

@Ambrevar
Copy link

Ambrevar commented Sep 7, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant