File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,11 +96,11 @@ def deserialize o
9696 Float ( @ss . tokenize ( o . value ) )
9797 when "!ruby/regexp"
9898 klass = class_loader . regexp
99- o . value =~ /^\/ (.*)\/ ([mixn]*)$/m
100- source = $1
99+ matches = /^\/ (?<string> .*)\/ (?<options> [mixn]*)$/m . match ( o . value )
100+ source = matches [ :string ] . gsub ( '\/' , '/' )
101101 options = 0
102102 lang = nil
103- $2& .each_char do |option |
103+ matches [ :options ] . each_char do |option |
104104 case option
105105 when 'x' then options |= Regexp ::EXTENDED
106106 when 'i' then options |= Regexp ::IGNORECASE
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ def test_multiline_regexp
3535 assert_cycle ( Regexp . new ( "foo\n bar" ) )
3636 end
3737
38+ def test_regexp_with_slash
39+ assert_cycle ( Regexp . new ( '/' ) )
40+ end
41+
3842 # [ruby-core:34969]
3943 def test_regexp_with_n
4044 assert_cycle ( Regexp . new ( '' , Regexp ::NOENCODING ) )
You can’t perform that action at this time.
0 commit comments