Skip to content

pad

pad(string, length, char?) → string · String

Pad a string on the left to the given length. Default pad character is space.

  • string (required): the string to pad

  • length (required): target length

  • char (optional): pad character (default " ")

bash
echo '{"id": "42"}' | utlx -e 'pad($input.id, 5, "0")'
# "00042"
utlx
{
  invoiceNo: pad(toString($input.seq), 8, "0")
}

Released under AGPL-3.0.