[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78793] [Ruby trunk Feature#13048] Better way to do Regexp.new(Regexp.escape("some string"))
From:
justcolin@...
Date:
2016-12-21 19:17:58 UTC
List:
ruby-core #78793
Issue #13048 has been updated by Colin Fulton.
It would be nice to have a real/more-idiomatic way instead of a hack, and that hack doesn't support duck typing, while adding `#to_regexp` to `String` does.
----------------------------------------
Feature #13048: Better way to do Regexp.new(Regexp.escape("some string"))
https://bugs.ruby-lang.org/issues/13048#change-62201
* Author: Colin Fulton
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
It is relatively common to call `Regexp.new(Regexp.escape("some string"))` or `Regexp.new(Regexp.quote("some string"))` in Ruby (a quick search turns up over half a million matches in Github). However, these seems rather cumbersome. It would be nice to have a class instance method on `Regexp` and/or an instance method on `String` to go directly to an escaped regular expression.
Personally I'd rather see `#to_regexp` added to `String`. This would not overlap with the functionality that `Rexexp.new("string")` provides since that doesn't quote the `String`.
It would also be good to see [9846](https://bugs.ruby-lang.org/issues/9846) addressed along with this request so one could more easily duck type a method to accept both `Regexp` and `String` arguments.
Thoughts?
--
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>