rfind
fn rfind(string hay, string needle) -> int Import
Source: use text::{rfind}; src/text.hy Returns the byte offset of the last needle in hay, or -1.
Parameters#
| Name | Type |
|---|---|
hay | string |
needle | string |
Returns#
int
Contracts#
Checked according to --contracts (see Contracts).
ensures result >= -1 && result <= hay.len()
ensures result < 0 || match_at(hay, needle, result)
Examples#
use text::{rfind};
use tests::assert;
assert!(rfind("a=b=c", "=") == 3);
See also#
byte_len: Returns the length ofsin bytes; the same ass.len().slice: Returns the part ofsfrom byte offsetstartup to (not including)end.trim_start: Returnsswithout leading ASCII whitespace (space, tab, CR, LF).trim_end: Returnsswithout trailing ASCII whitespace (space, tab, CR, LF).trim: Returnsswithout leading and trailing ASCII whitespace (space, tab, CR, LF).split_at: Splitssat byte offsetatinto the part before and the part fromaton.join: Returns thepartsconcatenated withsepbetween each pair.repeat: Returnssrepeatedntimes; empty whenn <= 0.