D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
String
/
Filename :
rindex-i.ri
back
Copy
U:RDoc::AnyMethod[iI"rindex:ETI"String#rindex;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"RReturns the Integer 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'.rindex('f') # => 0 ;TI"'foo'.rindex('o') # => 2 ;TI"'foo'.rindex('oo') # => 1 ;TI""'foo'.rindex('ooo') # => nil ;T:@format0o; ; [I"RReturns the Integer index of the _last_ match for the given Regexp +regexp+, ;TI"or +nil+ if none found:;T@o;; [ I"'foo'.rindex(/f/) # => 0 ;TI"'foo'.rindex(/o/) # => 2 ;TI"'foo'.rindex(/oo/) # => 1 ;TI""'foo'.rindex(/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'.rindex(/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'.rindex(/(?<!o)o+/) # => 1 ;TI"$~ #=> #<MatchData "oo"> ;T; 0o; ; [I"/Or String#index with negative lookforward.;T@o;; [I"%'foo'.index(/o+(?!.*o)/) # => 1 ;TI"$~ #=> #<MatchData "oo"> ;T; 0o; ; [I"jInteger argument +offset+, if given and non-negative, specifies the maximum starting position in the ;TI" string to _end_ the search:;T@o;; [ I"#'foo'.rindex('o', 0) # => nil ;TI"!'foo'.rindex('o', 1) # => 1 ;TI"!'foo'.rindex('o', 2) # => 2 ;TI"!'foo'.rindex('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'.rindex('o', -1) # => 2 ;TI""'foo'.rindex('o', -2) # => 1 ;TI"$'foo'.rindex('o', -3) # => nil ;TI"$'foo'.rindex('o', -4) # => nil ;T; 0o; ; [I"Related: String#index.;T: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below0I"vrindex(substring, offset = self.length) -> integer or nil rindex(regexp, offset = self.length) -> integer or nil ;T0[ I"(p1, p2 = v2);T@NFI"String;TcRDoc::NormalClass00