Skip to content

remove n chars from start or end of a string  #208

@lemongrassnginger

Description

@lemongrassnginger

Is there a method for removing n characters from the left or right of a string? Similar to left and right but providing the number of characters to remove rather than keep?

I've had a look but I can't seem to come up with a better way than the following, which works but is a bit long-winded for a string processing library:

// remove the last two characters
s = S('abcde')
s.left(s.length - 2).s
// "abc"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions