D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
String
/
Filename :
byterindex-i.ri
back
Copy
U:RDoc::AnyMethod[iI"byterindex:ETI"String#byterindex;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"]Returns the Integer byte-based index of the _last_ occurrence of the given +substring+, ;TI"or +nil+ if none found:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I""'foo'.byterindex('f') # => 0 ;TI""'foo'.byterindex('o') # => 2 ;TI"#'foo'.byterindex('oo') # => 1 ;TI"&'foo'.byterindex('ooo') # => nil ;T:@format0o; ; [I"]Returns the Integer byte-based index of the _last_ match for the given Regexp +regexp+, ;TI"or +nil+ if none found:;T@o;; [ I""'foo'.byterindex(/f/) # => 0 ;TI""'foo'.byterindex(/o/) # => 2 ;TI"#'foo'.byterindex(/oo/) # => 1 ;TI"&'foo'.byterindex(/ooo/) # => nil ;T; 0o; ; [I"HThe _last_ match means starting at the possible last position, not ;TI"!the last of longest matches.;T@o;; [I"#'foo'.byterindex(/o+/) # => 2 ;TI"$~ #=> #<MatchData "o"> ;T; 0o; ; [I"CTo get the last longest match, needs to combine with negative ;TI"lookbehind.;T@o;; [I")'foo'.byterindex(/(?<!o)o+/) # => 1 ;TI"$~ #=> #<MatchData "oo"> ;T; 0o; ; [I"3Or String#byteindex with negative lookforward.;T@o;; [I")'foo'.byteindex(/o+(?!.*o)/) # => 1 ;TI"$~ #=> #<MatchData "oo"> ;T; 0o; ; [I"uInteger argument +offset+, if given and non-negative, specifies the maximum starting byte-based position in the ;TI" string to _end_ the search:;T@o;; [ I"''foo'.byterindex('o', 0) # => nil ;TI"%'foo'.byterindex('o', 1) # => 1 ;TI"%'foo'.byterindex('o', 2) # => 2 ;TI"%'foo'.byterindex('o', 3) # => 2 ;T; 0o; ; [I"MIf +offset+ is a negative Integer, the maximum starting position in the ;TI"Ostring to _end_ the search is the sum of the string's length and +offset+:;T@o;; [ I"&'foo'.byterindex('o', -1) # => 2 ;TI"&'foo'.byterindex('o', -2) # => 1 ;TI"('foo'.byterindex('o', -3) # => nil ;TI"('foo'.byterindex('o', -4) # => nil ;T; 0o; ; [I"RIf +offset+ does not land on character (codepoint) boundary, +IndexError+ is ;TI"raised.;T@o; ; [I"Related: String#byteindex.;T: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below0I"}byterindex(substring, offset = self.bytesize) -> integer or nil byterindex(regexp, offset = self.bytesize) -> integer or nil ;T0[ I"(p1, p2 = v2);T@RFI"String;TcRDoc::NormalClass00