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 |
---|---|
list<string> | list<bool> |
record | record |
string | bool |
table | table |
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 │
╰───┴───────╯