Skip to main content

$startsWith

The $startsWith operator checks if the first string starts with the second string.

Input

  • An array containing exactly two string values: the main string and the prefix to check

Output

  • true if the first string starts with the second string
  • false otherwise

Examples

Starts With

{
  "$startsWith": [
    "Hello, world!",
    "Hello"
  ]
}
Result: true

Does Not Start With

{
  "$startsWith": [
    "Hello, world!",
    "world"
  ]
}
Result: false

Field Value

{
  "$startsWith": [
    {
      "$input": "filename"
    },
    "report_"
  ]
}
Result: true if the filename field starts with “report_”, otherwise false