ruby-changes:72959
From: Nobuyoshi <ko1@a...>
Date: Thu, 18 Aug 2022 23:25:24 +0900 (JST)
Subject: [ruby-changes:72959] c53667691a (master): [DOC] `offset` argument of Regexp#match
https://git.ruby-lang.org/ruby.git/commit/?id=c53667691a From c53667691a52bcaea4314974201c53dfc282cd95 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 18 Aug 2022 23:25:05 +0900 Subject: [DOC] `offset` argument of Regexp#match --- re.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/re.c b/re.c index a633d1bb7b..5091f9a124 100644 --- a/re.c +++ b/re.c @@ -3499,13 +3499,18 @@ rb_reg_match2(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L3499 * * With no block given, returns the MatchData object * that describes the match, if any, or +nil+ if none; - * the search begins at the given byte +offset+ in +self+: + * the search begins at the given character +offset+ in +string+: * * /abra/.match('abracadabra') # => #<MatchData "abra"> * /abra/.match('abracadabra', 4) # => #<MatchData "abra"> * /abra/.match('abracadabra', 8) # => nil * /abra/.match('abracadabra', 800) # => nil * + * string = "\u{5d0 5d1 5e8 5d0}cadabra" + * /abra/.match(string, 7) #=> #<MatchData "abra"> + * /abra/.match(string, 8) #=> nil + * /abra/.match(string.b, 8) #=> #<MatchData "abra"> + * * With a block given, calls the block if and only if a match is found; * returns the block's value: * -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/