str contains
for strings> str contains {flags} (string) ...rest
--ignore-case, -i
: search is case insensitive--not, -n
: does not containstring
: the substring to find...rest
: For a data structure input, check strings at the given cell paths, and replace with resultinput | output |
---|---|
list<string> | list<bool> |
record | record |
string | bool |
table | table |
Check if input contains string
>'my_library.rb'|str contains'.rb'
true
Check if input contains string case insensitive
>'my_library.rb'|str contains-i'.RB'
true
Check if input contains string in a record
> { ColA:test, ColB:100 } |str contains'e'ColA
╭──────┬──────╮
│ColA│true│
│ColB│100│
╰──────┴──────╯
Check if input contains string in a table
> [[ColAColB]; [test100]] |str contains-i'E'ColA
╭───┬──────┬──────╮
│# │ ColA │ ColB │
├───┼──────┼──────┤
│0│true│100│
╰───┴──────┴──────╯
Check if input contains string in a table
> [[ColAColB]; [testhello]] |str contains'e'ColAColB
╭───┬──────┬──────╮
│# │ ColA │ ColB │
├───┼──────┼──────┤
│0│true│true│
╰───┴──────┴──────╯
Check if input string contains 'banana'
>'hello'|str contains'banana'
false
Check if list contains string
> [onetwothree] |str containso
╭───┬───────╮
│0│true│
│1│true│
│2│false│
╰───┴───────╯
Check if list does not contain string
> [onetwothree] |str contains-no
╭───┬───────╮
│0│false│
│1│false│
│2│true│
╰───┴───────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/str_contains.html