Skip to content

Inaccuracy in documentation of ansi_substr #774

Description

@robustessay

The documentation for ansi_substr states "works exactly like the original"
but this is not true because it can't be used as a replacement function
like base::substr. It would be nice to have this implemented.

packageVersion('cli')
[1] '3.6.5'
x = '1234567890'
base::substr(x,3,5)
[1] "345"
base::substr(x,3,5) = 'ABC'
x
[1] "12ABC67890"
cli::ansi_substr(x,3,5)
<cli_ansi_string>
[1] ABC

But try as replacement:

cli::ansi_substr(x,3,5) = 'XYZ'
Error: 'ansi_substr<-' is not an exported object from 'namespace:cli'

Activity

  1. gaborcsardi commented on Jun 23, 2025

    @gaborcsardi
    Member

    ansi_substr<-() is a different function from ansi_substr().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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