-
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give .chomp the possibility to specify a needle (#4739)
Basically: say "foobar".chomp("bar"); # foo say "foobar".chomp("baz"); # foobar
- Loading branch information
Showing
2 changed files
with
8 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cccc3e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have previously thought about this feature, but thought it might be a better fit for
trim
and friends (trim-leading
,trim-trailing
).Indeed, Python's
trim
-family equivalents (strip
,lstrip
, andrstrip
) kind of do this, but tread the argument as a list of possible removalsWhich Raku can replicate with
subst
, a Regex character class, and an anchor... but perhaps a future feature for Rakutrim
might be - yes, add this needle functionality fromchomp
- but also add the ability to supply a Regex, eg."barxbar".trim-trailing(/<[arb]>/)
. Is that too much TIMTOWTDI?