method str.find
Byte index of the first occurrence of needle.
Example:
fn main() io {
print("ab".repeat(3))
}Вывод
ababab
Example:
fn main() io {
print("a-b-c".replace("-", "+"))
}Вывод
a+b+c
Example:
fn main() io {
print("{"one\ntwo".lines()}")
}Вывод
["one", "two"]
Example:
fn main() io {
print("{" a b\tc ".splitWhitespace()}")
}Вывод
["a", "b", "c"]
Example:
fn main() io {
print("{"a,b,,c".split(",")}")
}Вывод
["a", "b", "", "c"]
Example:
fn main() io {
print("[{" hi ".trimEnd()}]")
}Вывод
[ hi]
Example:
fn main() io {
print("[{" hi ".trimStart()}]")
}Вывод
[hi ]
Example:
fn main() io {
print("[{" hi \n".trim()}]")
}Вывод
[hi]
Example:
fn main() io {
print("Hello".upper())
}Вывод
HELLO
Example:
fn main() io {
print("Hello".lower())
}Вывод
hello
Example:
fn main() io {
print("{"hello".find("l")} {"hello".find("z")}")
}Вывод
2 none
pub(api) fn find(needle: str) -> usize?С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
needle | str |
Возвращает
usize?
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/text.oxl:328