find_from
fn find_from(string hay, string needle, int start) -> int Import
Source: use string::{find_from}; compiler/src/builtin_docs/string.hy Returns the byte offset of the first needle in hay at or after start, or -1.
start is clamped to 0..=hay.len(). An empty needle matches at the
clamped start. Offsets are byte offsets.
Parameters#
| Name | Type |
|---|---|
hay | string |
needle | string |
start | int |
Returns#
int
Examples#
use string::{find_from};
use tests::assert;
assert!(find_from("a-b-c", "-", 0) == 1);
assert!(find_from("a-b-c", "-", 2) == 3);
assert!(find_from("a-b-c", "x", 0) == -1);
assert!(find_from("abc", "", 10) == 3);
See also#
byte_at: Returns the byte at byte offsetiofs, or-1wheniis out of range.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.rfind: Returns the byte offset of the lastneedleinhay, or-1.slice_bytes: Returns the part ofsbetween byte offsetsstart(inclusive) andend(exclusive).to_bytes: Encodessas UTF-8 into a newVec<byte>.