split_at
fn split_at(string s, int at) -> Result<(string, string), string> Import
Source: use text::{split_at}; src/text.hy Splits s at byte offset at into the part before and the part from at on.
Parameters#
| Name | Type |
|---|---|
s | string |
at | int |
Returns#
Result<(string, string), string>
Errors#
Returns Err("utf8") when at falls inside a multi-byte character.
Examples#
use text::{split_at};
use tests::assert;
let (a, b) = split_at("hello", 2) ?? ("", "");
assert!(a == "he" && b == "llo");
See also#
byte_len: Returns the length ofsin bytes; the same ass.len().slice: Returns the part ofsfrom byte offsetstartup to (not including)end.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.join: Returns thepartsconcatenated withsepbetween each pair.repeat: Returnssrepeatedntimes; empty whenn <= 0.