stringTruncate := string_truncate(Args{text: "hello world", length: 5})
send_text_message(Args{
channel_id: trigger.channel_id,
message_content: "String: " + stringTruncate,
})
Inputs
StringRequired
String to truncate.
Example: hello world
LengthRequired
Maximum length.
Example: 5
Add Ellipses
Append an ellipsis when the string is truncated.
Optionsfalsetrue
Outputs
String
Truncated string.
Example: hello
Build a bot using blocks like Truncate String
Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.
Advanced Documentation
This documentation can be useful when using code mode. View as Markdown
ID:
string_truncate- Value block: it can be used directly inside expressions, e.g.
"Result: " + string_truncate(Args{...}).
Inputs
| Field | InventScript name | Value |
|---|---|---|
| String | text | e.g. "hello world" |
| Length | length | e.g. "5" |
| Add Ellipses | add_ellipses | "false", "true" |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| String | string | e.g. "hello" |
Example InventScript
More strings blocks
String LengthGet the length of a string in characters and in bytes.String Split ListSplit a string into a list of strings with a delimiter.Split String IteratorIterate over a string separated by a delimiter.String Contains CountCount the number of times a substring appears in a string.String ReplaceReplace a substring with a new substring within a string.String to LowercaseConvert a string to lowercase.String to UppercaseConvert a string to uppercase.String Trim PrefixRemove a prefix from a string.String Trim SuffixRemove a suffix from a string.Base64 EncodeEncode a string to Base64.Base64 DecodeDecode a Base64 string.Format NumberFormat a number with commas.Generate UUIDv4Generate a UUIDv4 (fully-random).Generate UUIDv7Generate a UUIDv7 (time-based).Parse ColorParse a color string (name or hex code) into a hex string.URL Query EscapeEncode a string to be used as a URL parameter.URL Query UnescapeDecode a string used as a URL parameter.Bcrypt Hash StringApply a one-way hash to a string using bcrypt.Bcrypt Compare HashCompare a string to a bcrypt hash.Verify HMACVerify a message against an HMAC signature.MD5 HashGenerate an MD5 hash of a string.Sort Lines by Number Prefix or SuffixSort lines of text by the number at the beginning or end of each line.Truncate Split String ListSplit a string into groups of a certain number of characters.Truncate Split String IteratorIterate over a string by groups of a certain number of characters.Scramble StringScramble the order of characters in a string.Random String GeneratorGenerate a random string of a specified length using a chosen character set.Repeat StringRepeat a string a specified number of times.Reverse StringReverse the characters of a string.Reorder Comma Separated ListReorder the elements in a comma separated list.Intersection of Comma Separated ListsCompare two comma separated lists and find items exclusive to each list and items common to both.Remap StringRemap or replace values in a string using a set of original-to-replacement pairs.Get UUIDv7 Creation TimeGet the creation time of a UUIDv7.