strings.containsStr() function

The strings.containsStr() function reports whether a string contains a specified substring.

*Output data type: Boolean*

  1. import "strings"
  2. strings.containsStr(v: "This and that", substr: "and")
  3. // returns true

Parameters

v

The string value to search.

*Data type: String*

substr

The substring value to search for.

*Data type: String*

Examples

Report if a string contains a specific substring
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. _value: strings.containsStr(v: r.author, substr: "John")
  6. })
  7. )

Related articles