Skip to content

Introduce String::remove_matches to remove all matches of a pattern in a string. #50206

Description

@frewsxcv

Like replace(..., ""), but doesn't result in any allocations.

I started implementing this in #50015 but got stuck, mainly because of limitations in the Pattern APIs.

let mut s = String::from("Trees are not green, the sky is not blue.");
s.remove_matches("not ");
assert_eq!("Trees are green, the sky is blue.", s);

This issue has been assigned to @jcotton42 via this comment.

Activity

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

Metadata

Metadata

Assignees

Labels

C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-api[DEPRECATED; DO NOT USE]

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions