str index-of
for strings> str index-of {flags} (string) ...rest
--grapheme-clusters, -g
: count indexes using grapheme clusters (all visible chars have length 1)--utf-8-bytes, -b
: count indexes using UTF-8 bytes (default; non-ASCII chars have length 2+)--range, -r {range}
: optional start and/or end index--end, -e
: search from the end of the inputstring
: the string to find in the input...rest
: For a data structure input, search strings at the given cell paths, and replace with resultinput | output |
---|---|
list<string> | list<int> |
record | record |
string | int |
table | table |
Returns index of string in input
>'my_library.rb'|str index-of'.rb'
10
Count length using grapheme clusters
>'๐ฏ๐ตใปใ ใตใ ใดใ'|str index-of-g'ใตใ'
4
Returns index of string in input within arhs open range
>'.rb.rb'|str index-of'.rb'-r1..
3
Returns index of string in input within a lhs open range
>'123456'|str index-of'6'-r..4
-1
Returns index of string in input within a range
>'123456'|str index-of'3'-r1..4
2
Returns index of string in input
>'/this/is/some/path/file.txt'|str index-of'/'-e
18
Copyright ยฉ 2019โ2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/str_index-of.html