Skip to content

Allow :preserve-case on partial word match #51

@Ambrevar

Description

@Ambrevar

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions