str contains for strings
Checks if string input contains a substring.
Signature
> str contains {flags} (string) ...rest
Flags
-
--ignore-case, -i: Search is case insensitive.
Parameters
-
string: The substring to find. -
...rest: For a data structure input, check strings at the given cell paths, and replace with result.
Input/output types:
| input | output |
|---|---|
| string | bool |
| table | table |
| record | record |
| list<string> | list<bool> |
Examples
Check if input contains string.
> 'my_library.rb' | str contains '.rb' true
Check if input contains string case insensitive.
> 'my_library.rb' | str contains --ignore-case '.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.
> [[ColA ColB]; [test 100]] | str contains --ignore-case 'E' ColA ╭───┬──────┬──────╮ │ # │ ColA │ ColB │ ├───┼──────┼──────┤ │ 0 │ true │ 100 │ ╰───┴──────┴──────╯
Check if input contains string in a table.
> [[ColA ColB]; [test hello]] | str contains 'e' ColA ColB ╭───┬──────┬──────╮ │ # │ ColA │ ColB │ ├───┼──────┼──────┤ │ 0 │ true │ true │ ╰───┴──────┴──────╯
Check if input string contains 'banana'.
> 'hello' | str contains 'banana' false
Check if list contains string.
> [one two three] | str contains o ╭───┬───────╮ │ 0 │ true │ │ 1 │ true │ │ 2 │ false │ ╰───┴───────╯
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/str_contains.html