diff options
author | Shugo Maeda <[email protected]> | 2024-06-12 11:35:53 +0900 |
---|---|---|
committer | Shugo Maeda <[email protected]> | 2024-07-16 14:48:06 +0900 |
commit | e048a073a3cba04576b8f6a1673c283e4e20cd90 () | |
tree | f8eb52ab8d61192f2afb29c815db8deeddc7d94b /test/ruby/test_regexp.rb | |
parent | a887b41875d00637064294be7059335599937f17 (diff) |
Add MatchData#bytebegin and MatchData#byteend
These methods return the byte-based offset of the beginning or end of the specified match. [Feature #20576]
-rw-r--r-- | test/ruby/test_regexp.rb | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -559,16 +559,26 @@ class TestRegexp < Test::Unit::TestCase assert_raise(IndexError) { m.byteoffset(2) } assert_raise(IndexError) { m.begin(2) } assert_raise(IndexError) { m.end(2) } m = /(?<x>q..)?/.match("foobarbaz") assert_equal([nil, nil], m.byteoffset("x")) assert_equal(nil, m.begin("x")) assert_equal(nil, m.end("x")) m = /\A\u3042(.)(.)?(.)\z/.match("\u3042\u3043\u3044") assert_equal([3, 6], m.byteoffset(1)) assert_equal([nil, nil], m.byteoffset(2)) assert_equal([6, 9], m.byteoffset(3)) end def test_match_to_s |