slice
fn slice(string s, int start, int end) -> Result<string, string> Import
Source: use text::{slice}; src/text.hy Returns the part of s from byte offset start up to (not including) end.
Parameters#
| Name | Type |
|---|---|
s | string |
start | int |
end | int |
Returns#
Result<string, string>
Errors#
Returns Err("utf8") when an offset falls inside a multi-byte character.
Examples#
use text::{slice};
use tests::assert;
assert!((slice("hello", 1, 4) ?? "") == "ell");
See also#
byte_len: Returns the length ofsin bytes; the same ass.len().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).rfind: Returns the byte offset of the lastneedleinhay, or-1.split_at: Splitssat byte offsetatinto the part before and the part fromaton.join: Returns thepartsconcatenated withsepbetween each pair.repeat: Returnssrepeatedntimes; empty whenn <= 0.