Skip to content

Commit 909a0da

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] More tweaks for String#byteindex
1 parent f483bef commit 909a0da

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

string.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4965,13 +4965,16 @@ str_ensure_byte_pos(VALUE str, long pos)
49654965
* s.byteindex('ooo') # => nil
49664966
*
49674967
* When +object+ is a Regexp,
4968-
* returns the index of the first found substring matching +object+:
4968+
* returns the index of the first found substring matching +object+;
4969+
* updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables]:
49694970
*
49704971
* s = 'foo'
49714972
* s.byteindex(/f/) # => 0
4973+
* $~ # => #<MatchData "f">
49724974
* s.byteindex(/o/) # => 1
49734975
* s.byteindex(/oo/) # => 1
49744976
* s.byteindex(/ooo/) # => nil
4977+
* $~ # => nil
49754978
*
49764979
* \Integer argument +offset+, if given, specifies the 0-based index
49774980
* of the byte where searching is to begin.
@@ -4992,7 +4995,7 @@ str_ensure_byte_pos(VALUE str, long pos)
49924995
* s.byteindex('o', -3) # => 1
49934996
* s.byteindex('o', -4) # => nil
49944997
*
4995-
* Raises IndexError if +offset+ does not land of a character boundary:
4998+
* Raises IndexError if the byte at +offset+ is not the first byte of a character:
49964999
*
49975000
* s = "\uFFFF\uFFFF" # => "\uFFFF\uFFFF"
49985001
* s.size # => 2 # Two 3-byte characters.

0 commit comments

Comments
 (0)