Skip to content

startsWith

startsWith(string, prefix) → boolean · String

Check if a string starts with a given substring.

  • string (required): the string to test

  • prefix (required): the substring to check for

bash
echo '{"orderId": "ORD-001"}' | utlx -e 'startsWith($input.orderId, "ORD-")'
# true
utlx
if (!startsWith($input.id, "ORD-")) error("Invalid order ID format")
{
  validFormat: startsWith($input.orderId, "ORD-"),
  orderId: $input.orderId
}

Released under AGPL-3.0.