Help Center/ Log Tank Service/ User Guide/ Log Processing/ DSL Data Processing Syntax (Beta)/ Operator Functions/ String Functions/ Multiple Character Strings, Sorting, Inversion, and Replacement
Updated on 2025-09-07 GMT+08:00

Multiple Character Strings, Sorting, Inversion, and Replacement

str_format

  • Format
    str_format(format, str1, str2, ...)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    format

    string

    Yes

    Format after conversion

    str1

    Any

    Yes

    Value 1 to be formatted

    str2

    Any

    Yes

    Value 2 to be formatted

  • Returned result

    Formatted string.

  • Function example
    • Test data: none
    • Processing rule
      e_set("result", str_format("{}={}", "lts", 8))
    • Processing result
      result: lts=8

str_join

  • Format
    str_join(connector, str1, str2, ...)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    connector

    Any (automatically converted to string)

    Yes

    Connector, for example, number sign (#), dollar sign ($), and percent (%).

    str1

    Any (automatically converted to string)

    Yes

    Value 1 to be connected.

    str2

    Any (automatically converted to string)

    Yes

    Value 2 to be connected.

  • Returned result

    Concatenated character string.

  • Function example
    • Test data: none
    • Processing rule
      e_set("email", str_join("@", "lts", "aa", "com"))
    • Processing result
      email:  lts@aa@com

str_zip

  • Format
    str_zip(value1,value2,combine_sep=None,sep=None,quote=None,lparse=None,rparse=None)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    value1

    Any (automatically converted to string)

    Yes

    Values to be combined.

    value2

    Any (automatically converted to string)

    Yes

    Values to be combined.

    combine_sep

    Any (automatically converted to string)

    No

    Identifier for combining elements. The default value is #.

    sep

    Any (automatically converted to string)

    No

    Separator between elements after combination. Only a single character is supported. The default value is ,.

    quote

    Any (automatically converted to string)

    No

    Character used to enclose combined elements. This parameter is required when the value contains a separator. The default value is ".

    lparse

    Any (automatically converted to string)

    No

    Separator and quotation mark between elements in value1. The default separator is , and the default quotation mark is ". The format is lparse =(',', '"').

    Note: The quotation mark takes precedence over the separator.

    rparse

    Any (automatically converted to string)

    No

    Separator and quotation mark between elements in value2. The default separator is , and the default quotation mark is ". The format is rparse =(',', '"').

    Note: The quotation mark takes precedence over the separator.

  • Returned result

    Combined character string.

  • Function example
    1. Example 1: sep usage.
      • Test data
        {
         "key1": "value1,value11",
         "key2": "value2,value21"
        }
      • Processing rule
        e_set("combine", str_zip(v("key1"), v("key2"), sep="|"))
      • Processing result
        key1: value1,value11 
        key2: value2,value21 
        combine: value1#value2|value11#value21
    2. Example 2: Use of quote.
      • Test data
        {
          "key1": "\"value1, value2\", value3, \"value4,value5\"",
          "key2": "value11,\"value12,value13\",value14"
        }
      • Processing rule
        e_set("combine", str_zip(v("key1"), v("key2"), quote='|'))
      • Processing result
        key1: "value1, value2", value3, "value4,value5"
        key2: value11,"value12,value13",value14 
        combine: |value1,value2#value11|,|value3#value12,value13|,|value4,value5#value14|
    3. Example 3: Values of different lengths.
      • Test data
        {
         "key1": "value1,value2",
         "key2": "value11,value12,value13"
        }
      • Processing rule
        e_set("combine", str_zip(v("key1"), v("key2")))
      • Processing result
        key1: value1,value2 
        key2: value11,value12,value13 
        combine: value1#value11,value2#value12
    4. Example 4: Usage of lparse and rparse.
      • Test data
        {
         "key1": "|value1, value1|, value2, |value3,value3|",
         "key2": "value11, #value12,value12#, value13"
        }
      • Processing rule
        e_set("combine", str_zip(v("key1"), v("key2"), lparse=(",", '|'), rparse=(",", '#')))
      • Processing result
        key1: |value1, value1|, value2, |value3,value3|
        key2: value11, #value12,value12#, value13
        combine: "value1,value1#value11","value2#value12,value12","value3,value3#value13"

str_sort

  • Format
    str_sort(value, reverse=false)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    value

    Any (automatically converted to string)

    Yes

    Original string to be sorted.

    reverse

    Boolean

    No

    The default value is false, indicating that the values are sorted in ascending order.

  • Returned result

    Sorted string.

  • Function example
    • Test data
      {
       "key1": "value"
      }
    • Processing rule
      e_set("str_sort", str_sort(v("key1")))
    • Processing result
      key1: value 
      str_sort: aeluv

str_reverse

  • Format
    str_reverse(value)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    value

    Any (automatically converted to string)

    Yes

    Value to be reversed.

  • Returned result

    Reversed string.

  • Function example
    • Test data
      { 
        "data": "switch"
      }
    • Processing rule
      e_set("reverse_data", str_reverse(v("data")))
    • Processing result
      data: switch 
      reverse_data: hctiws

str_replace

  • Format
    str_replace(value, old, new, count)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    value

    Any (automatically converted to string)

    Yes

    Value to be replaced.

    old

    Any (automatically converted to string)

    Yes

    String to be replaced.

    new

    Any (automatically converted to string)

    Yes

    New string after replacement.

    count

    Number

    No

    Number of replacement times. This parameter is optional. If count is not set, all occurrences will be replaced.

  • Returned result

    New string after replacement.

  • Function example
    • Test data: none
    • Processing rule
      e_set("str_replace", str_replace("this is string example", "is", "was"))
    • Processing result
      str_replace: thwas was string example

str_translate

  • Format
    str_translate(value, replace_string, mapping_string)
  • Parameter description

    Parameter

    Type

    Mandatory

    Description

    value

    Any (automatically converted to string)

    Yes

    Original string to be replaced.

    replace_string

    Any (automatically converted to string)

    Yes

    Character set to be replaced.

    mapping_string

    Any (automatically converted to string)

    Yes

    Character set after replacement.

  • Returned result

    Processed string.

  • Function example
    • Test data: none
    • Processing rule
      e_set("str_translate", str_translate("lts", "ts", "34"))
    • Processing result
      str_translate: l34