Function in text coil-stdlib

rfind

fn rfind(string hay, string needle) -> int
Import
use text::{rfind};
Source: src/text.hy

Returns the byte offset of the last needle in hay, or -1.

Parameters#

NameType
haystring
needlestring

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 of s in bytes; the same as s.len().
  • slice: Returns the part of s from byte offset start up to (not including) end.
  • trim_start: Returns s without leading ASCII whitespace (space, tab, CR, LF).
  • trim_end: Returns s without trailing ASCII whitespace (space, tab, CR, LF).
  • trim: Returns s without leading and trailing ASCII whitespace (space, tab, CR, LF).
  • split_at: Splits s at byte offset at into the part before and the part from at on.
  • join: Returns the parts concatenated with sep between each pair.
  • repeat: Returns s repeated n times; empty when n <= 0.
↑ ↓ navigate ↵ open