method str.find
Byte index of the first occurrence of needle.
Example:
fn main() io {
print("ab".repeat(3))
}Output
ababab
Example:
fn main() io {
print("a-b-c".replace("-", "+"))
}Output
a+b+c
Example:
fn main() io {
print("{"one\ntwo".lines()}")
}Output
["one", "two"]
Example:
fn main() io {
print("{" a b\tc ".splitWhitespace()}")
}Output
["a", "b", "c"]
Example:
fn main() io {
print("{"a,b,,c".split(",")}")
}Output
["a", "b", "", "c"]
Example:
fn main() io {
print("[{" hi ".trimEnd()}]")
}Output
[ hi]
Example:
fn main() io {
print("[{" hi ".trimStart()}]")
}Output
[hi ]
Example:
fn main() io {
print("[{" hi \n".trim()}]")
}Output
[hi]
Example:
fn main() io {
print("Hello".upper())
}Output
HELLO
Example:
fn main() io {
print("Hello".lower())
}Output
hello
Example:
fn main() io {
print("{"hello".find("l")} {"hello".find("z")}")
}Output
2 none
pub(api) fn find(needle: str) -> usize?Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
needle | str |
Returns
usize?
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/text.oxl:328