diff options
author | BurdetteLamar <[email protected]> | 2025-05-25 09:59:52 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2025-05-26 13:42:35 -0400 |
commit | 909a0daab696c7b9dc1d23d27500e1eecd93e470 (patch) | |
tree | 617a28fb21197eab827a4d4ac5143a8f25c2e03b | |
parent | f483befd9065d159d3a944b87fe26179c5373c30 (diff) |
[DOC] More tweaks for String#byteindex
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13440
-rw-r--r-- | string.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -4965,13 +4965,16 @@ str_ensure_byte_pos(VALUE str, long pos) * s.byteindex('ooo') # => nil * * When +object+ is a Regexp, - * returns the index of the first found substring matching +object+: + * returns the index of the first found substring matching +object+; + * updates {Regexp-related global variables}[rdoc-ref:Regexp@Global+Variables]: * * s = 'foo' * s.byteindex(/f/) # => 0 + * $~ # => #<MatchData "f"> * s.byteindex(/o/) # => 1 * s.byteindex(/oo/) # => 1 * s.byteindex(/ooo/) # => nil + * $~ # => nil * * \Integer argument +offset+, if given, specifies the 0-based index * of the byte where searching is to begin. @@ -4992,7 +4995,7 @@ str_ensure_byte_pos(VALUE str, long pos) * s.byteindex('o', -3) # => 1 * s.byteindex('o', -4) # => nil * - * Raises IndexError if +offset+ does not land of a character boundary: + * Raises IndexError if the byte at +offset+ is not the first byte of a character: * * s = "\uFFFF\uFFFF" # => "\uFFFF\uFFFF" * s.size # => 2 # Two 3-byte characters. |