[comment]: # attributes: notoc

[comment]: # translation:outdated

[comment]: # ({new-b12f316b})
# 8 String functions

All functions listed here are supported in:

-   [Trigger expressions](/manual/config/triggers/expression)
-   [Calculated items](/manual/config/items/itemtypes/calculated)

Some general notes on function parameters:

-   Function parameters are separated by a comma
-   Expressions are accepted as parameters
-   String parameters must be double-quoted; otherwise they might get
    misinterpreted
-   Optional function parameters (or parameter parts) are indicated by
    `<` `>`

|FUNCTION|<|<|<|
|--------|-|-|-|
|<|**Description**|**Function-specific parameters**|**Comments**|
|**ascii** (value)|<|<|<|
|<|The ASCII code of the leftmost character of the value.|**value** - value to check|Supported value types: string, text, log<br><br>For example, a value like 'Abc' will return '65' (ASCII code for 'A').<br><br>Example:<br>=> **ascii**(last(/host/key))|
|**bitlength** (value)|<|<|<|
|<|The length of value in bits.|**value** - value to check|Supported value types: string, text, log, integer<br><br>Example:<br>=> **bitlength**(last(/host/key))|
|**bytelength** (value)|<|<|<|
|<|The length of value in bytes.|**value** - value to check|Supported value types: string, text, log, integer<br><br>Example:<br>=> **bytelength**(last(/host/key))|
|**char** (value)|<|<|<|
|<|Return the character by interpreting the value as ASCII code.|**value** - value to check|Supported value types: integer<br><br>The value must be in the 0-255 range. For example, a value like '65' (interpreted as ASCII code) will return 'A'.<br><br>Example:<br>=> **char**(last(/host/key))|
|**concat** (value,string)|<|<|<|
|<|The string resulting from concatenating the value to the specified string.|**value** - value to check<br>**string** - the string to concatenate to|Supported value types: string, text, log<br><br>For example, a value like 'Zab' concatenated to 'bix' (the specified string) will return 'Zabbix'.<br><br>Example:<br>=> **concat**(last(/host/key),**"bix"**)|
|**insert** (value,start,length,replacement)|<|<|<|
|<|Insert specified characters or spaces into the character string beginning at the specified position in the string.|**value** - value to check<br>**start** - start position<br>**length** - positions to replace<br>**replacement** - replacement string|Supported value types: string, text, log<br><br>For example, a value like 'Zabbbix' will be replaced by 'Zabbix' if 'bb' (starting position 3, positions to replace 2) is replaced by 'b'.<br><br>Example:<br>=> **insert**(last(/host/key),**3**,**2**,**"b"**)|
|**left** (value,count)|<|<|<|
|<|The leftmost characters of the value.|**value** - value to check<br>**count** - number of characters to return|Supported value types: string, text, log<br><br>For example, you may return 'Zab' from 'Zabbix' by specifying 3 leftmost characters to return.<br><br>Example:<br>=> **left**(last(/host/key),**3**) - return three leftmost characters<br><br>See also right().|
|**length** (value)|<|<|<|
|<|The length of value in characters.|**value** - value to check|Supported value types: str, text, log<br><br>Example:<br>=> **length**(last(/host/key)) → length of the latest value<br>=> **length**(last(/host/key,\#3)) → length of the third most recent value<br>=> **length**(last(/host/key,\#1:now-1d)) → length of the most recent value one day ago|
|**ltrim** (value,<chars>)|<|<|<|
|<|Remove specified characters from the beginning of string.|**value** - value to check<br>**chars** - (optional) specify characters to remove<br><br>Whitespace is left-trimmed by default (if no optional characters are specified).|Supported value types: string, text, log<br><br>Example:<br>=> **ltrim**(last(/host/key)) - remove whitespace from the beginning of string<br>=> **ltrim**(last(/host/key),**"Z"**) - remove any 'Z' from the beginning of string<br>=> **ltrim**(last(/host/key),**" Z"**) - remove any space and 'Z' from the beginning of string<br><br>See also: rtrim(), trim()|
|**mid** (value,start,length)|<|<|<|
|<|Return a substring of N characters beginning at the character position specified by 'start'.|**value** - value to check<br>**start** - start position of substring<br>**length** - positions to return in substring|Supported value types: string, text, log<br><br>For example, it is possible return 'abbi' from a value like 'Zabbix' if starting position is 2, and positions to return is 4).<br><br>Example:<br>=> **mid**(last(/host/key),**2**,**4**)="abbi"|
|**repeat** (value,count)|<|<|<|
|<|Repeat a string.|**value** - value to check<br>**count** - number of times to repeat|Supported value types: string, text, log<br><br>Example:<br>=> **repeat**(last(/host/key),**2**) - repeat the value two times|
|**replace** (value,pattern,replacement)|<|<|<|
|<|Find pattern in the value and replace with replacement. All occurrences of the pattern will be replaced.|**value** - value to check<br>**pattern** - pattern to find<br>**replacement** - string to replace the pattern with|Supported value types: string, text, log<br><br>Example:<br>=> **replace**(last(/host/key),**"ibb"**,**"abb"**) - replace all 'ibb' with 'abb'|
|**right** (value,count)|<|<|<|
|<|The rightmost characters of the value.|**value** - value to check<br>**count** - number of characters to return|Supported value types: string, text, log<br><br>For example, you may return 'bix' from 'Zabbix' by specifying 3 rightmost characters to return.<br><br>Example:<br>=> **right**(last(/host/key),**3**) - return three rightmost characters<br><br>See also left().|
|**rtrim** (value,<chars>)|<|<|<|
|<|Remove specified characters from the end of string.|**value** - value to check<br>**chars** - (optional) specify characters to remove<br><br>Whitespace is right-trimmed by default (if no optional characters are specified).|Supported value types: string, text, log<br><br>Example:<br>=> **rtrim**(last(/host/key)) - remove whitespace from the end of string<br>=> **rtrim**(last(/host/key),**"x"**) - remove any 'x' from the end of string<br>=> **rtrim**(last(/host/key),**"x "**) - remove any 'x' or space from the end of string<br><br>See also: ltrim(), trim()|
|**trim** (value,<chars>)|<|<|<|
|<|Remove specified characters from the beginning and end of string.|**value** - value to check<br>**chars** - (optional) specify characters to remove<br><br>Whitespace is trimmed from both sides by default (if no optional characters are specified).|Supported value types: string, text, log<br><br>Example:<br>=> **trim**(last(/host/key)) - remove whitespace from the beginning and end of string<br>=> **trim**(last(/host/key),**"\_"**) - remove '\_' from the beginning and end of string<br><br>See also: ltrim(), rtrim()|

[comment]: # ({/new-b12f316b})

[comment]: # ({new-af8a7af1})
### Function details

Some general notes on function parameters:

-   Function parameters are separated by a comma
-   Expressions are accepted as parameters
-   String parameters must be double-quoted; otherwise they might get
    misinterpreted
-   Optional function parameters (or parameter parts) are indicated by
    `<` `>`

[comment]: # ({/new-af8a7af1})

[comment]: # ({new-4273ccdf})

##### ascii(value) {#ascii}

The ASCII code of the leftmost character of the value.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check

For example, a value like 'Abc' will return '65' (ASCII code for 'A').

Example:

    ascii(last(/host/key))

[comment]: # ({/new-4273ccdf})

[comment]: # ({new-d7034056})

##### bitlength(value) {#bitlength}

The length of value in bits.<br>
Supported value types: *String*, *Text*, *Log*, *Integer*.

Parameter: 

-   **value** - the value to check

Example:

    bitlength(last(/host/key))

[comment]: # ({/new-d7034056})

[comment]: # ({new-dce34bc3})

##### bytelength(value) {#bytelength}

The length of value in bytes.<br>
Supported value types: *String*, *Text*, *Log*, *Integer*.

Parameter: 

-   **value** - the value to check

Example:

    bytelength(last(/host/key))

[comment]: # ({/new-dce34bc3})

[comment]: # ({new-e7b45303})

##### char(value) {#char}

Return the character by interpreting the value as ASCII code.<br>
Supported value types: *Integer*.

Parameter: 

-   **value** - the value to check

The value must be in the 0-255 range. For example, a value like '65' (interpreted as ASCII code) will return 'A'.

Example:

    char(last(/host/key))

[comment]: # ({/new-e7b45303})

[comment]: # ({new-0126c3dc})

##### concat(<value1>,<value2>,...) {#concat}

The string resulting from concatenating the referenced item values or constant values.<br>
Supported value types: *String*, *Text*, *Log*, *Float*, *Integer*.

Parameter: 

-   **valueX** - the value returned by one of the history functions or a constant value (string, integer, or float number). Must contain at least two parameters.

For example, a value like 'Zab' concatenated to 'bix' (the constant string) will return 'Zabbix'.

Examples:

    concat(last(/host/key),"bix")
    concat("1 min: ",last(/host/system.cpu.load[all,avg1]),", 15 min: ",last(/host/system.cpu.load[all,avg15]))

[comment]: # ({/new-0126c3dc})

[comment]: # ({new-a177adcc})

##### insert(value,start,length,replacement) {#insert}

Insert specified characters or spaces into the character string beginning at the specified position in the string.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **start** - start position;<br>
-   **length** - positions to replace;<br>
-   **replacement** - replacement string.

For example, a value like 'Zabbbix' will be replaced by 'Zabbix' if 'bb' (starting position 3, positions to replace 2) is replaced by 'b'.

Example:

    insert(last(/host/key),3,2,"b")

[comment]: # ({/new-a177adcc})

[comment]: # ({new-cd30d53b})

##### left(value,count) {#left}

Return the leftmost characters of the value.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **count** - the number of characters to return.

For example, you may return 'Zab' from 'Zabbix' by specifying 3 leftmost characters to return. See also [right()](#right).

Example:

    left(last(/host/key),3) #return three leftmost characters

[comment]: # ({/new-cd30d53b})

[comment]: # ({new-22f2d5bf})

##### length(value) {#length}

The length of value in characters.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check.

Examples:

    length(last(/host/key)) #the length of the latest value
    length(last(/host/key,#3)) #the length of the third most recent value
    length(last(/host/key,#1:now-1d)) #the length of the most recent value one day ago

[comment]: # ({/new-22f2d5bf})

[comment]: # ({new-9e85b495})

##### ltrim(value,<chars>) {#ltrim}

Remove specified characters from the beginning of string.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **chars** (optional) - specify the characters to remove.

Whitespace is left-trimmed by default (if no optional characters are specified). See also: [rtrim()](#rtrim), [trim()](#trim).

Examples:

    ltrim(last(/host/key)) #remove whitespace from the beginning of string
    ltrim(last(/host/key),"Z") #remove any 'Z' from the beginning of string
    ltrim(last(/host/key)," Z") #remove any space and 'Z' from the beginning of string

[comment]: # ({/new-9e85b495})

[comment]: # ({new-cc4186d4})

##### mid(value,start,length) {#mid}

Return a substring of N characters beginning at the character position specified by 'start'.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **start** - start position of the substring;<br>
-   **length** - positions to return in substring.

For example, it is possible return 'abbi' from a value like 'Zabbix' if starting position is 2, and positions to return is 4.

Example:

    mid(last(/host/key),2,4)="abbi"

[comment]: # ({/new-cc4186d4})

[comment]: # ({new-fae77b9a})

##### repeat(value,count) {#repeat}

Repeat a string.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **count** - the number of times to repeat.

Example:

    repeat(last(/host/key),2) #repeat the value two times

[comment]: # ({/new-fae77b9a})

[comment]: # ({new-f0625b19})

##### replace(value,pattern,replacement) {#replace}

Find the pattern in the value and replace with replacement. All occurrences of the pattern will be replaced.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **pattern** - the pattern to find;<br>
-   **replacement** - the string to replace the pattern with.

Example:

    replace(last(/host/key),"ibb","abb") - replace all 'ibb' with 'abb'

[comment]: # ({/new-f0625b19})

[comment]: # ({new-800b9846})

##### right(value,count) {#right}

Return the rightmost characters of the value.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **count** - the number of characters to return.

For example, you may return 'bix' from 'Zabbix' by specifying 3 rightmost characters to return. See also [left()](#left).

Example:

    right(last(/host/key),3) #return three rightmost characters

[comment]: # ({/new-800b9846})

[comment]: # ({new-75f38780})

##### rtrim(value,<chars>) {#rtrim}

Remove specified characters from the end of string.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **chars** (optional) - specify the characters to remove.

Whitespace is right-trimmed by default (if no optional characters are specified). See also: [ltrim()](#ltrim), [trim()](#trim).

Examples:

    rtrim(last(/host/key)) #remove whitespace from the end of string
    rtrim(last(/host/key),"x") #remove any 'x' from the end of string
    rtrim(last(/host/key),"x ") #remove any 'x' and space from the end of string

[comment]: # ({/new-75f38780})

[comment]: # ({new-621e8d68})

##### trim(value,<chars>) {#trim}

Remove specified characters from the beginning and end of string.<br>
Supported value types: *String*, *Text*, *Log*.

Parameter: 

-   **value** - the value to check;<br>
-   **chars** (optional) - specify the characters to remove.

Whitespace is trimmed from both sides by default (if no optional characters are specified). See also: [ltrim()](#ltrim), [rtrim()](#rtrim).

Examples:

    trim(last(/host/key)) - remove whitespace from the beginning and end of string
    trim(last(/host/key),"_") - remove '_' from the beginning and end of string

[comment]: # ({/new-621e8d68})

[comment]: # ({new-2bfdbb8f})

See [all supported functions](/manual/appendix/functions).

[comment]: # ({/new-2bfdbb8f})
