match_at
fn match_at(string s, string needle, int at) -> bool Import
Source: use string::{match_at}; compiler/src/builtin_docs/string.hy Returns whether needle occurs in s starting exactly at byte offset at.
false when at is negative or the match would run past the end.
An empty needle matches at any offset in 0..=s.len().
Parameters#
| Name | Type |
|---|---|
s | string |
needle | string |
at | int |
Returns#
bool
Examples#
use string::{match_at};
use tests::assert;
assert!(match_at("key=value", "=", 3));
assert!(!match_at("key=value", "=", 2));
assert!(!match_at("ab", "abc", 0));
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.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>.