From: nobu@... Date: 2016-08-23T11:39:53+00:00 Subject: [ruby-core:77020] [Ruby trunk Feature#12694] Want a String method to remove heading substr Issue #12694 has been updated by Nobuyoshi Nakada. IIRC, there were proposals of `lstrip` and `rstrip` enhancement. I'd expect them to accept char class(es), than a sub-string. Note that `rb_str_index_m` accepts a `Regexp` too. Calling `str_strlen` on it will segfault. ---------------------------------------- Feature #12694: Want a String method to remove heading substr https://bugs.ruby-lang.org/issues/12694#change-60247 * Author: Naotoshi Seo * Status: Open * Priority: Normal * Assignee: ---------------------------------------- I often write codes like: ```ruby str = 'abcdef' substr = 'abc' str[substr.size..-1] if str.index(substr) == 0 #=> 'def' # or str.sub(/^#{substr}/, '') #=> 'def' ``` I want a short hand which is something like: ```ruby str = 'abcdef' substr = 'abc' str.rstrip(substr) #=> 'def' ``` Having similar argument for `String#lstrip` would be nice for symmetry although we already have `String#chomp(substr)` -- https://bugs.ruby-lang.org/ Unsubscribe: