1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[DOC] offset argument of Regexp#match

This commit is contained in:
Nobuyoshi Nakada 2022-08-18 23:25:05 +09:00
parent b0b9f7201a
commit c53667691a
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

7
re.c
View file

@ -3499,13 +3499,18 @@ rb_reg_match2(VALUE re)
* *
* With no block given, returns the MatchData object * With no block given, returns the MatchData object
* that describes the match, if any, or +nil+ if none; * 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') # => #<MatchData "abra">
* /abra/.match('abracadabra', 4) # => #<MatchData "abra"> * /abra/.match('abracadabra', 4) # => #<MatchData "abra">
* /abra/.match('abracadabra', 8) # => nil * /abra/.match('abracadabra', 8) # => nil
* /abra/.match('abracadabra', 800) # => 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; * With a block given, calls the block if and only if a match is found;
* returns the block's value: * returns the block's value:
* *