str contains for strings

Checks if string input contains a substring.

Signature

> str contains (string) ...rest --ignore-case --not

Parameters

  • string: the substring to find
  • ...rest: For a data structure input, check strings at the given cell paths, and replace with result
  • --ignore-case (-i): search is case insensitive
  • --not (-n): does not contain

Input/output types:

inputoutput
list<string>list<bool>
recordrecord
stringbool
tabletable

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 -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

>  [[ColA ColB]; [test 100]] | str contains -i 'E' ColA
╭───┬──────┬──────╮
│ # │ ColA │ ColB │
├───┼──────┼──────┤
│ 0true100 │
╰───┴──────┴──────╯

Check if input contains string in a table

>  [[ColA ColB]; [test hello]] | str contains 'e' ColA ColB
╭───┬──────┬──────╮
│ # │ ColA │ ColB │
├───┼──────┼──────┤
│ 0truetrue │
╰───┴──────┴──────╯

Check if input string contains 'banana'

> 'hello' | str contains 'banana'
false

Check if list contains string

> [one two three] | str contains o
╭───┬───────╮
│ 0true  │
│ 1true  │
│ 2false │
╰───┴───────╯

Check if list does not contain string

> [one two three] | str contains -n o
╭───┬───────╮
│ 0false │
│ 1false │
│ 2true  │
╰───┴───────╯