rfind
fn rfind(string hay, string needle) -> int Import
Source: use string::{rfind}; compiler/src/builtin_docs/string.hy Returns the byte offset of the last needle in hay, or -1.
An empty needle matches at hay.len().
Parameters#
| Name | Type |
|---|---|
hay | string |
needle | string |
Returns#
int
Examples#
use string::{rfind};
use tests::assert;
assert!(rfind("a/b/c", "/") == 3);
assert!(rfind("abc", "x") == -1);
assert!(rfind("abc", "") == 3);
See also#
byte_at: Returns the byte at byte offsetiofs, or-1wheniis out of range.find_from: Returns the byte offset of the firstneedleinhayat or afterstart, or-1.format: Builds a string from the literalfmtand the arguments that follow it.from_bytes: Decodesbytesas UTF-8 text.match_at: Returns whetherneedleoccurs insstarting exactly at byte offsetat.slice_bytes: Returns the part ofsbetween byte offsetsstart(inclusive) andend(exclusive).to_bytes: Encodessas UTF-8 into a newVec<byte>.