[ruby-core:77178] [Ruby trunk Feature#12694] Want a String method to remove heading substr
From:
sonots@...
Date:
2016-09-07 06:48:20 UTC
List:
ruby-core #77178
Issue #12694 has been updated by Naotoshi Seo.
Description updated
----------------------------------------
Feature #12694: Want a String method to remove heading substr
https://bugs.ruby-lang.org/issues/12694#change-60392
* Author: Naotoshi Seo
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
I often write codes like:
```ruby
str = 'abcdef'
substr = 'abc'
str[substr.size..-1] if str.start_with?(substr) #=> 'def'
# or
str.sub(/^#{Regexp.escape(substr)}/, '') #=> 'def'
```
I want a short hand which is something like:
```ruby
str = 'abcdef'
substr = 'abc'
str.lstrip(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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>