OxL Reference

method str.find

Byte index of the first occurrence of needle.

Example:

oxl✓ checked in CI
fn main() io {
  print("ab".repeat(3))
}
Output
ababab

Example:

oxl✓ checked in CI
fn main() io {
  print("a-b-c".replace("-", "+"))
}
Output
a+b+c

Example:

oxl✓ checked in CI
fn main() io {
  print("{"one\ntwo".lines()}")
}
Output
["one", "two"]

Example:

oxl✓ checked in CI
fn main() io {
  print("{" a  b\tc ".splitWhitespace()}")
}
Output
["a", "b", "c"]

Example:

oxl✓ checked in CI
fn main() io {
  print("{"a,b,,c".split(",")}")
}
Output
["a", "b", "", "c"]

Example:

oxl✓ checked in CI
fn main() io {
  print("[{"  hi ".trimEnd()}]")
}
Output
[  hi]

Example:

oxl✓ checked in CI
fn main() io {
  print("[{"  hi ".trimStart()}]")
}
Output
[hi ]

Example:

oxl✓ checked in CI
fn main() io {
  print("[{"  hi \n".trim()}]")
}
Output
[hi]

Example:

oxl✓ checked in CI
fn main() io {
  print("Hello".upper())
}
Output
HELLO

Example:

oxl✓ checked in CI
fn main() io {
  print("Hello".lower())
}
Output
hello

Example:

oxl✓ checked in CI
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

NameType
needlestr

Returns

usize?

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/text.oxl:328

See also