Description
The truncate
function is used to shorten a string by a specified number of characters.
Parameters
- string (mandatory): The string to be truncated.
- start (mandatory): The starting character index to truncate from.
- end (optional): The ending character index to truncate to. If not provided, the string will be truncated to the end of the string.
- ellipsis (mandatory): A boolean value indicating whether to add an ellipsis (...) to the end of the truncated string.
Examples
truncate("Hello, World!", start=5, ellipsis=true)
returns", World!"
truncate("This is a long string.", start=9, end=15, ellipsis=false)
returns" long "