Actions
Bug #14608
closedRegexp::union and forward slashes
Description
When using Regexp::union and a regular expression with a forward slash, there seem to be some inconsistencies.
# this is weird
Regexp.union(/\//, '') # => /(?-mix:\/)|/
Regexp.union(/\//, '') == /(?-mix:\/)|/ # => false
# here is the difference
Regexp.union(/\//, '').source # => "(?-mix:\\/)|"
/(?-mix:\/)|/.source # => "(?-mix:/)|"
Previously reported at https://github.com/janosch-x/js_regex/issues/6
Updated by shevegen (Robert A. Heiler) over 6 years ago
Interesting. I would have expected them to be the same.
Would be nice if it could be explained in the official docs
too at http://ruby-doc.org/core-2.5.0/Regexp.html#method-c-union
Updated by nobu (Nobuyoshi Nakada) over 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r62779.
re.c: do not escape terminator in Regexp.union
-
re.c (rb_reg_str_with_term): change terminator.
-
re.c (rb_reg_s_union): terminator in source string does not need
to be escaped. terminators are outside of regexp source itself.
[ruby-core:86149] [Bug #14608]
Actions
Like0
Like0Like0