From: "shugo (Shugo Maeda) via ruby-core" Date: 2025-12-04T06:30:16+00:00 Subject: [ruby-core:124021] [Ruby Feature#21552] allow String.strip and similar to take a parameter similar to String.delete Issue #21552 has been updated by shugo (Shugo Maeda). Suggested by nobu, I've added documentation and tests for character selectors: https://github.com/ruby/ruby/pull/15400/commits/a9ad44007dbb0ea543ce1eb8748edd4213083c5f Exmaples: ``` "012abc345".strip("0-9") # "abc" "012abc345".strip("^a-z") # "abc" ``` Unlike String#delete, the current implementation doesn't take multiple arguments. I'm not sure whether there's a use case for it. ---------------------------------------- Feature #21552: allow String.strip and similar to take a parameter similar to String.delete https://bugs.ruby-lang.org/issues/21552#change-115453 * Author: MSP-Greg (Greg L) * Status: Open ---------------------------------------- Regrading `String.strip` (and `lstrip`, `rstrip`, and `!` versions) Some text data representations differentiate between what one might call vertical and horizontal white space, and the 'strip' methods currently strip both. It would be helpful if they had an optional parameter similar to `String.delete` with a one multi-character selector, so one could do: ```ruby t = str.strip " \t" ``` One can use a regex for this, but this much simpler. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/