diff --git a/re.c b/re.c index e513c2ca17..1264733f6b 100644 --- a/re.c +++ b/re.c @@ -666,6 +666,11 @@ match_backref_number(VALUE match, VALUE backref) * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.offset(0) #=> [1, 7] * m.offset(4) #=> [6, 7] + * + * m = /(?.)(.)(?.)/.match("hoge") + * p m.offset(:foo) #=> [0, 1] + * p m.offset(:bar) #=> [2, 3] + * */ static VALUE @@ -694,6 +699,10 @@ match_offset(VALUE match, VALUE n) * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.begin(0) #=> 1 * m.begin(2) #=> 2 + * + * m = /(?.)(.)(?.)/.match("hoge") + * p m.begin(:foo) #=> 0 + * p m.begin(:bar) #=> 2 */ static VALUE @@ -721,6 +730,10 @@ match_begin(VALUE match, VALUE n) * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.end(0) #=> 7 * m.end(2) #=> 3 + * + * m = /(?.)(.)(?.)/.match("hoge") + * p m.end(:foo) #=> 1 + * p m.end(:bar) #=> 3 */ static VALUE @@ -1284,11 +1297,15 @@ match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end, * * Returns a printable version of mtch. * - * /.$/ =~ "foo"; puts $~.inspect + * puts /.$/.match("foo").inspect * #=> # * - * /(.)(.)(.)/ =~ "foo"; puts $~.inspect - * #=> # + * puts /(.)(.)(.)/.match("foo").inspect + * #=> # + * + * puts /(?.)(?.)(?.)/.match("hoge").inspect + * #=> # + * */ static VALUE diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index f052b946c0..09022629d5 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -57,7 +57,6 @@ class TestRegexp < Test::Unit::TestCase assert_equal(5, m.begin(:foo)) assert_equal(8, m.end(:foo)) assert_equal([5,8], m.offset(:foo)) - #assert_equal(["amp"], m.values_at(:foo)) assert_equal("aaa [amp] yyy", "aaa & yyy".sub(/&(?.*?);/, '[\k]'))