Issue #21552 has been updated by Eregon (Benoit Daloze). This sounds like a lot of complexity for one specific use-case, which already has a good solution with `sub`. From the benchmarks, `lstrip("\0 \t-\r")` and `sub(/\A[\0\s]+/, "")` are pretty close. `sub(/[\0\s]+\z/, "")` is slower than `rstrip("\0 \t-\r")`, but that sounds more like something that could/should be optimized in the regexp engine (and would benefit far more cases than this specific one). ---------------------------------------- Feature #21552: allow String.strip and similar to take a parameter similar to String.delete https://bugs.ruby-lang.org/issues/21552#change-115576 * 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/