Skip to content

String Substring

How to trim part of a string in a chat bot

{{ substr($Variable, 0, 3) }}

where: 0 - character index to start trimming from (Important! numbering starts at zero, i.e. 0 is the first character, 1 is the second character, 2 is the third character, etc.); 3 - number of characters to keep in the string;

For example, the value "abcdef" is stored in variable $Строка

{{ substr($Строка, 0, 3) }} -> abc

{{ substr($Строка, 1, 2) }} -> bc

{{ substr($Строка, 3) }} -> def

{{ substr($Строка, -1, 1) }} -> f

{{ substr($Строка, -2, 1) }} -> e

Using this solution, you can, for example, extract part of a phone number if it is saved in a variable.

In the LEADTEX personal account, 250+ lessons on chat bot and MiniApp development are already available, as well as the opportunity to join the largest developer community with 6000+ participants - Go to personal account.