All Products
Search
Document Center

Simple Log Service:String functions

Last Updated:Jun 10, 2026

Describes the syntax, parameters, and usage examples of string functions in SLS data transformation.

Functions

Category

Function

Description

Multi-string operation

str_format

Formats strings in a specified format.

str_join

Concatenates strings with a specified connector.

str_zip

Splits two expression values and combines the results into one string.

Encoding and decoding

str_encode

Encodes a string using a specified encoding format.

str_decode

Decodes an input value using a specified encoding format.

str_hex_escape_encode

Escapes special characters, including hexadecimal sequences to their readable form.

str_uuid

Generates a random UUID.

Sorting, reversing, and replacement

str_sort

Sorts a specified object.

str_reverse

Reverses a string.

str_replace

Replaces a substring based on a specified rule.

str_logstash_config_normalize

Converts the data in the Logstash configuration language to the JSON format.

str_translate

Replaces characters in a string based on a mapping table.

Regular munging

str_strip

Deletes specified characters from a string.

str_lstrip

Deletes specified characters from the start of a string.

str_rstrip

Deletes specified characters from the end of a string.

str_lower

Converts all uppercase letters to lowercase.

str_upper

Converts all lowercase letters to uppercase.

str_title

Capitalizes the first letter of each word and lowercases the rest.

str_capitalize

Capitalizes the first letter and lowercases the rest.

str_swapcase

Swaps the case of all letters in a string.

Search and check

str_count

Counts the number of occurrences of a character in a string.

str_find

Checks whether a string contains a specified substring.

str_rfind

Returns the position of the last occurrence of a substring.

str_endswith

Checks whether a string ends with a specified suffix.

str_startswith

Checks whether a string starts with a specified prefix.

Splitting

str_split

Splits a string using a specified delimiter.

str_splitlines

Splits a string using a line feed.

str_partition

Splits a string into three parts from left to right using a specified delimiter.

str_rpartition

Splits a string into three parts from right to left using a specified delimiter.

Formatting

str_center

Pads a string to a specified length using a specified character.

str_ljust

Right pads a string to a specified length using a specified character.

str_rjust

Left pads a string to a specified length using a specified character.

str_zfill

Left pads a string to a specified length using 0.

str_expandtabs

Converts the \t character in a string to spaces.

Character set check

str_isalnum

Checks whether a string contains only letters and digits.

str_isalpha

Checks whether a string contains only letters.

str_isascii

Checks whether a string is in the ASCII table.

str_isdecimal

Checks whether a string contains only decimal characters.

str_isdigit

Checks whether a string contains only digits.

str_isidentifier

Checks whether a string is a valid Python identifier.

str_islower

Checks whether a string contains only lowercase letters.

str_isnumeric

Checks whether all characters in a string are numeric.

str_isprintable

Checks whether all characters in a string are printable characters.

str_isspace

Checks whether a string contains only spaces.

str_istitle

Checks whether the first letter of each word in a string is in uppercase and the other letters in the string are in lowercase.

str_isupper

Checks whether all letters in a string are in uppercase.

You can use string functions with the following functions:

Category

Function

Description

Multi-string operation

op_add

Returns the sum value of multiple numeric values or strings.

op_max

Returns the maximum value among multiple numeric values or strings.

op_min

Returns the minimum value among multiple numeric values or strings.

String truncation

op_slice

Truncates a string.

Length calculation

op_len

Returns the length of a string.

str_format

Formats a string using a specified format.

  • Syntax

    str_format(format_string, value1, value2, ...)
  • Parameters

    Parameter

    Data Type

    Required

    Description

    format_string

    Arbitrary (auto-converted to string)

    Yes

    The format of the output string. Example: {}={}.

    value1

    Arbitrary

    Yes

    The value to format.

    value2

    Arbitrary

    Yes

    The value to format.

  • Response

    Returns a formatted string.

  • Examples

    • Raw log

      class: Format
      escape_name: Traditional
    • Transformation rule

      e_set("str_format", str_format("{}={}", v("class"), v("escape_name")))
    • Result

      class: Format
      escape_name: Traditional
      str_format: Format=Traditional

str_join

Combines the input strings into a single string separated by a delimiter.

  • Syntax

    str_join(connector, value1,  value2, ....)
  • Parameters

    Parameter

    Data type

    Required

    Description

    connector

    Arbitrary (auto-converted to string)

    Yes

    The connector. Supported connectors include the exclamation point (!), at sign (@), number sign (#), dollar sign ($), and percent sign (%).

    value1

    Arbitrary (auto-converted to string)

    Yes

    The value to concatenate.

    value2

    Arbitrary (auto-converted to string)

    Yes

    The value to concatenate.

  • Response

    Returns a concatenated string.

  • Examples

    • Raw log

      name: ETL
      company: aliyun.com
    • Transformation rule

      e_set("email", str_join("@", v("name"), v("company")))
    • Result

      name: ETL
      company: aliyun.com
      email:ETL@aliyun.com

str_encode

Encodes the string using the specified encoding format.

  • Syntax

    str_encode(value, "utf8", errors="ignore")
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to encode.

    encoding

    String

    No

    The encoding format. Default value: UTF-8. ASCII is supported.

    errors

    String

    No

    The method that is used to process characters if the characters cannot be recognized based on the encoding format. Valid values:

    • ignore (default): The characters are not encoded.

    • strict: An error is reported, and the log is discarded.

    • replace: The unrecognizable characters are replaced with question marks (?).

    • xmlcharrefreplace: The unrecognizable characters are replaced with XML characters.

  • Response

    Returns an encoded string.

  • Examples

    • Example 1

      • Raw log

        test: asewds
      • Transformation rule

        e_set("f1", str_decode(str_encode("Hello", "utf8"), "utf8"))
      • Result

        test: asewds
        f1: Hello
    • Example 2

      • Raw log

        f2: test Test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="ignore"))
      • Result

        f1:test 
        f2:test Test data
    • Example 3

      • Raw log

        f2: test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="strict"))
      • Result

        An error is reported during execution.

    • Example 4

      • Raw log

        f2: test Test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="replace"))
      • Result

        f1:test ????
        f2:test Test data
    • Example 5

      • Raw log

        f2: test Test data
      • Transformation rule

        e_set("f1", str_encode(v("f2"), "ascii", errors="xmlcharrefreplace"))
      • Result

        f1:test 测试数据
        f2:test Test data

str_decode

Decodes the input value using the specified encoding format.

  • Syntax

    str_decode(value, "utf8", errors="ignore")
    Note

    The str_decode function can process only the data of the byte data type.

  • Parameters

    Parameter Name

    Data Types

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to decode.

    encoding

    Arbitrary (auto-converted to string)

    No

    The encoding format. Default value: UTF-8. ASCII is supported.

    errors

    Arbitrary (auto-converted to string)

    No

    The method that is used to process characters if the characters cannot be recognized based on the encoding format. Valid values:

    • ignore (default): The characters are not decoded.

    • strict: An error is reported, and the log is discarded.

    • replace: The unrecognizable characters are replaced with question marks (?).

    • xmlcharrefreplace: The unrecognizable characters are replaced with XML characters.

  • Response

    Returns a decoded value.

  • Examples

    • Raw log

      test: asewds
    • Transformation rule

      e_set("encoding", str_decode(b'\xe4\xbd\xa0\xe5\xa5\xbd', "utf8", 'strict'))
    • Result

      test: asewds
      encoding: Hello

str_replace

Replaces occurrences of an old substring with a new substring.

  • Syntax

    str_replace(value, old, new, count)
    Note

    This function supports basic variable parameters. Function invoking.

  • Parameters

    Parameter Name

    Data Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to replace.

    old

    Arbitrary (auto-converted to string)

    Yes

    The string to replace.

    new

    Arbitrary (auto-converted to string)

    Yes

    The string after the replacement.

    count

    Number

    No

    The number of replacements. If not specified, all occurrences are replaced.

  • Response

    Returns a new string.

  • Examples

    Convert a dictionary to the JSON format.

    • Raw log

      content:  {'referer': '-', 'request': 'GET /phpMyAdmin', 'status': 404, 'data-1': {'aaa': 'Mozilla', 'bbb': 'asde'}, 'data-2': {'up_adde': '-', 'up_host': '-'}}
    • Transformation rule

      e_set("content_json", str_replace(ct_str(v("content")),"'",'"'))
    • Result

      content:  {'referer': '-', 'request': 'GET /phpMyAdmin', 'status': 404, 'data-1': {'aaa': 'Mozilla', 'bbb': 'asde'}, 'data-2': {'up_adde': '-', 'up_host': '-'}}
      content_json:  {"referer": "-", "request": "GET /phpMyAdmin", "status": 404, "data-1": {"aaa": "Mozilla", "bbb": "asde"}, "data-2": {"up_adde": "-", "up_host": "-"}}

str_sort

Sorts the specified objects.

  • Syntax

    str_sort(value, reverse=False)
  • Parameters

    Parameter name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to sort.

    reverse

    Boolean

    No

    Default value: False, which indicates that the string is sorted in ascending order.

  • Response

    A sorted string is returned.

  • Examples

    • Example 1: Sort the value of the str field in alphabetical order.

      • Raw log

        str: twish
      • Transformation rule

        e_set("str_sort", str_sort(v("str")))
      • Result

        str: twish
        str_sort: histw
    • Example 2: Sort the string str in reverse order in groups of two.

      • Raw log

        str: twish
      • Transformation rule

        e_set("str_sort", str_sort(v("str"), reverse=True))
      • Result

        str: twish
        str_sort: wtsih

str_reverse

Reverses a string.

  • Syntax

    str_reverse(value)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to reverse.

  • Response

    Returns a reversed string.

  • Examples

    Reverse the value of the data field.

    • Raw log

      data:twish
    • Transformation rule

      e_set("reverse_data", str_reverse(v("data")))
    • Result

      data:twish
      reverse_data:hsiwt

str_logstash_config_normalize

You can convert a Logstash configuration to JSON format.

  • Syntax

    str_logstash_config_normalize(value)
    Note

    For Logstash configuration language details, see Logstash.

  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to convert.

  • Response

    Returns a converted string.

  • Examples

    Transform Logstash data.

    • Raw log

      logstash: {"name"=>"tw5"}
    • Transformation rule

      e_set("normalize_data", str_logstash_config_normalize(v("logstash")))
    • Result

      logstash: {"name"=>"tw5"}
      normalize_data:{"name":"tw5"}

str_hex_escape_encode

Escapes special characters and converts hexadecimal characters to Chinese characters.

  • Syntax

    str_hex_escape_encode(value)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The value to escape.

  • Response

    Returns an escaped string.

  • Examples

    Escape the value of the myfriend field to Chinese characters.

    • Raw log

      myfriend: \xE6\x9F\xB3\xE4\xBA\x91
    • Transformation rule

      e_set("hex_myfriend", str_hex_escape_encode("myfriend"))
    • Result

      hex_myfriend:myfriend
      myfriend:\xE6\x9F\xB3\xE4\xBA\x91

str_strip

Removes specified characters from a string.

  • Syntax

    str_strip(value, chars)
  • Parameters

    Parameter name

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    chars

    Arbitrary (auto-converted to string)

    No

    The character set to delete from the start and end of the specified string. Default value: \t\r\n.

  • Response

    Returns a new string.

  • Examples

    • Example 1: Delete the asterisks (*) from the start of the strip field value.

      • Raw log

        strip: ***I love Etl
      • Transformation rule

        e_set("str_strip", str_strip(v("strip"), "*"))
      • Result

        strip: ***I love Etl
        str_strip:I love Etl
    • Example 2: Strip the leading spaces.

      • Raw log

        strip:    I love Etl
      • Transformation rule

        e_set("str_strip", str_strip(v("strip")))
      • Result

        strip:    I love Etl
        str_strip: I love Etl
    • Example 3: Delete the xy character set.

      • Raw log

        strip:xy123yx
      • Transformation rule

        e_set("str_strip", str_strip(v("strip"), "xy"))
      • Result

        strip:xy123yx
        str_strip:123

str_lower

Converts all uppercase characters in a string to lowercase.

  • Syntax

    str_lower(value)
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to convert.

  • Response

    Returns a converted string.

  • Examples

    Convert the value of the name field to lowercase letters.

    • Raw log

      name: Etl
    • Transformation rule

      e_set("str_lower", str_lower(v("name")))
    • Result

      name: Etl
      str_lower: etl

str_upper

Converts all lowercase characters within a string to uppercase.

  • Syntax

    str_upper(value)
  • Parameters

    Parameter

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to convert.

  • Response

    Returns a converted string.

  • Examples

    Convert the value of the name field to uppercase letters.

    • Raw log

      name: etl
    • Transformation rule

      e_set("str_upper", str_upper(v("name")))
    • Result

      name: etl
      str_upper: ETL

str_title

Capitalize the first letter of each word and change the rest to lowercase.

  • Syntax

    str_title(value)
  • Parameters

    Parameter name

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to convert.

  • Response

    Returns a converted string.

  • Examples

    Capitalize the first letter of each word in the value of the word field.

    • Raw log

      word: this is etl
    • Transformation rule

      e_set("str_title", str_title(v("word")))
    • Result

      word: this is etl
      str_title: This Is Etl

str_capitalize

The str_capitalize function capitalizes the first letter and lowercases the rest.

  • Syntax

    str_capitalize(value)
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to convert.

  • Response

    Returns a converted string.

  • Examples

    Capitalize the first letter of the word field value and convert the other letters in the value to lowercase letters.

    • Raw log

      word: this Is MY EAL
    • Transformation rule

      e_set("str_capitalize", str_capitalize(v("word")))
    • Result

      word: this Is MY EAL
      str_capitalize: This is my eal

str_lstrip

The str_lstrip function deletes specified characters from the start of a string.

  • Syntax

    str_lstrip(value, chars)
  • Parameters

    Parameter Name

    Data Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    chars

    Arbitrary (auto-converted to string)

    No

    The character set to delete from the start of the string. Default value: space.

  • Response

    Returns a new string.

  • Examples

    • Example 1: Delete the asterisks (*) from the start of the word field value.

      • Raw log

        word: ***this is string
      • Transformation rule

        e_set("str_lstrip", str_lstrip(v("word"), "*"))
      • Result

        word: ***this is string
        str_lstrip: this is string
    • Example 2: Delete the spaces from the start of the word field value.

      • Raw log

        word:     this is string
      • Transformation rule

        e_set("str_lstrip", str_lstrip(v("word")))
      • Result

        word:     this is string
        str_lstrip: this is string
    • Example 3: Delete the xy character set.

      • Raw log

        lstrip:xy123yx
      • Transformation rule

        e_set("str_lstrip", str_lstrip(v("lstrip"),"xy"))
      • Result

        lstrip:xy123yx
        str_lstrip:123yx

str_rstrip

Removes the specified trailing character from a string.

  • Syntax

    str_rstrip(value, chars)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    chars

    Arbitrary (auto-converted to string)

    No

    The character set to delete from the end of the string. Default value: space.

  • Response

    Returns a new string.

  • Examples

    • Example 1: Delete the asterisks (*) from the end of the word field value.

      • Raw log

        word: this is string*****
      • Transformation rule

        e_set("str_rstrip", str_rstrip(v("word"), "*"))
      • Result

        word: this is string*****
        str_rstrip: this is string
    • Example 2: Delete the xy character set.

      • Raw log

        word:xy123yx
      • Transformation rule

        e_set("str_rstrip", str_rstrip(v("word"), "xy"))
      • Result

        word:xy123yx
        str_rstrip:xy123

str_swapcase

You can transform the case of a string.

  • Syntax

    str_swapcase(value)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to convert.

  • Response

    Returns a converted string.

  • Examples

    • Raw log

      name: this is string
    • Transformation rule

      e_set("str_swapcase", str_swapcase(v("name")))
    • Result

      name: this is string
      str_swapcase: THIS IS STRING

str_translate

The str_translate function replaces characters based on a mapping table.

  • Syntax

    str_translate(value, replace_string, mapping_string)
  • Parameters

    Parameter Name

    Data Types

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string in which to replace characters.

    replace_string

    Arbitrary (auto-converted to string)

    Yes

    The character set to replace.

    mapping_string

    Arbitrary (auto-converted to string)

    Yes

    The character set after the replacement.

  • Response

    Returns a new string.

  • Examples

    • Raw log

      name: I love ETL!!!
    • Transformation rule

      e_set("str_translate", str_translate(v("name"), "aeiou", "12345"))
    • Result

      name: I love ETL!!!
      str_translate: I l4v2 ETL!!!

str_endswith

The str_endswith function checks whether a string ends with a specified suffix.

  • Syntax

    str_endswith(value, suffix, start, end)
    Note

    This function supports basic variable parameters. Function invoking.

  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to check.

    suffix

    Arbitrary (auto-converted to string)

    Yes

    The suffix. The value of this parameter can be a string or an element.

    start

    Number

    No

    The position from which the check starts.

    The value 0 specifies the first character. The value -1 specifies the last character.

    end

    Number

    No

    The position at which the check ends.

    The value 0 specifies the first character. The value -1 specifies the last character.

  • Response

    If the string ends with the specified suffix, True is returned. Otherwise, False is returned.

  • Examples

    • Raw log

      name: this is endswith!!!
    • Transformation rule

      e_set("str_endswith",str_endswith(v("name"), "!"))
    • Result

      name: this is endswith!!!
      str_endswith: True

str_startswith

The str_startswith function checks whether a string starts with a specified prefix.

  • Syntax

    str_startswith(value, prefix, start, end)
    Note

    This function supports basic variable parameters. Function invoking.

  • Parameters

    Parameter name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to check.

    prefix

    Arbitrary (auto-converted to string)

    Yes

    The prefix. The value of this parameter can be a string or an element.

    start

    Number

    No

    The position from which the check starts.

    The value 0 specifies the first character. The value -1 specifies the last character.

    end

    Number

    No

    The position at which the check ends.

    The value 0 specifies the first character. The value -1 specifies the last character.

  • Response

    If the string starts with the specified prefix, True is returned. Otherwise, False is returned.

  • Examples

    • Raw log

      name: !! this is startwith
    • Transformation rule

      e_set("str_startswith",str_startswith(v("name"), "!!"))
    • Result

      name: !! this is startwith
      str_startswith: True

str_find

Checks whether the source string contains the specified substring.

  • Syntax

    str_find(value, str, begin, end)
    Note

    This function supports basic variable parameters. Function invoking.

  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string in which to search for a substring.

    str

    Arbitrary (auto-converted to string)

    Yes

    The substring to search for.

    begin

    Number

    No

    The position from which the search starts.

    The default value 0 specifies the first character. The value -1 specifies the last character.

    end

    Number

    No

    The end position of the index.

    The default value is the length of the string. The value 0 specifies the first character. The value -1 specifies the last character.

  • Response

    Returns the position of the first occurrence of the specified substring.

  • Examples

    • Raw log

      name: hello world
    • Transformation rule

      e_set("str_find",str_find(v("name"), "h"))
    • Result

      name: hello world
      str_find: 0

str_count

The str_count function counts character occurrences in a string.

  • Syntax

    str_count(value, sub, start, end)
    Note

    This function supports basic variable parameters. Function invoking.

  • Parameters

    Parameter Name

    Data Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The source string for counting.

    sub

    Arbitrary (auto-converted to string)

    Yes

    The character whose number of occurrences you want to count.

    start

    Number

    No

    The position from which the search for the specified character starts in the string. Valid values:

    • 0 (default): the first character

    • -1: the last character

    end

    Number

    No

    The position at which the search for the specified character ends in the string. Valid values:

    • 0: the first character

    • -1 (default): the last character

  • Response

    Returns the number of occurrences of the specified character.

  • Examples

    • Raw log

      name: this is really a string
    • Transformation rule

      e_set("str_count", str_count(v("name"), "i"))
    • Result

      name: this is really a string
      str_count: 3

str_rfind

The str_rfind function returns the position of the last occurrence of a substring.

  • Syntax

    str_rfind(value, substr, beg, end)
    Note

    This function supports basic variable parameters. Function invoking.

  • Parameters

    Parameter Name

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The source string to search.

    substr

    Arbitrary (auto-converted to string)

    Yes

    The character to search for.

    beg

    Number

    No

    The position from which the search starts. Default value: 0.

    end

    Number

    No

    The position at which the search ends. The default value is the length of the string.

  • Response

    Returns the position of the last occurrence of the specified character or string.

  • Examples

    • Raw log

      name: this is really a string
    • Transformation rule

      e_set("str_rfind", str_rfind(v("name"), "i"))
    • Result

      name: this is really a string
      str_rfind: 20

str_split

Splits a string into substrings based on a specified separator.

  • Syntax

    str_split(value, sep=None, maxsplit=-1)
  • Parameters

    Parameter Name

    Data Types

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to split.

    sep

    Number

    No

    The delimiter. The value None specifies a space.

    maxsplit

    Number

    No

    The maximum number of substrings into which you can split the string. The value -1 specifies no limit.

  • Response

    Processed strings are returned.

  • Examples

    Split the value of the content field using the space delimiter.

    • Raw log

      content: hello world
    • Transformation rule

      e_set("str_split", str_split(v("content"), " "))
    • Result

      content: hello world
      str_split: ["hello", "world"]

str_splitlines

You can split a string on a line feed.

  • Syntax

    str_splitlines(value, keepends)
  • Parameters

    Parameter Name

    Data Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to split.

    keepends

    Boolean

    No

    Specifies whether to retain line feeds in the result. The line feeds include \r, \r\n, and \n. Default value: False, which specifies that line feeds are deleted. The value True specifies that line feeds are retained.

  • Response

    Returns the processed list.

  • Examples

    • Example 1

      • Raw log

        content: ab c\n\nde fg\rkl\r\n
      • Transformation rule

        e_set("str_splitlines", str_splitlines(v("content"), False))
      • Result

        content: ab c\n\nde fg\rkl\r\n
        str_splitlines: ['ab c', '', 'de fg', 'kl']
    • Example 2

      • Raw log

        content: ab c\n\nde fg\rkl\r\n
      • Transformation rule

        e_set("str_splitlines", str_splitlines(v("content"), True))
      • Result

        content: ab c\n\nde fg\rkl\r\n  
        str_splitlines: ['ab c\n', '\n', 'de fg\r', 'kl\r\n']

str_partition

The str_partition function splits a string into three parts from left to right using a specified delimiter.

  • Syntax

    str_partition(value, substr)
  • Parameters

    Parameter

    Data Types

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to split.

    substr

    Arbitrary (auto-converted to string)

    No

    The delimiter.

  • Response

    The split list is returned.

  • Examples

    Split the website field value into three parts from left to right using the . delimiter.

    • Raw log

      website: www.aliyun.com
    • Transformation rule

      e_set("str_partition", str_partition(v("website"), "."))
    • Result

      website: www.aliyun.com
      str_partition:  ["www", ".", "aliyun.com"]

str_rpartition

The str_rpartition function splits a string into three parts from right to left using a specified delimiter.

  • Syntax

    str_rpartition(value, substr)
  • Parameters

    Parameter name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to split.

    substr

    Arbitrary (auto-converted to string)

    No

    The delimiter.

  • Response

    Returns the processed list.

  • Examples

    Split the website field value into three parts from right to left using the . delimiter.

    • Raw log

      website: www.aliyun.com
    • Transformation rule

      e_set("str_partition", str_rpartition(v("website"), "."))
    • Result

        website: www.aliyun.com
        str_partition: ["www.aliyun", ".", "com"]

str_center

Pads a string to a specified length with a specified character.

  • Syntax

    str_center(value, width, fillchar)
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    width

    Number

    Yes

    The length of the string after padding.

    fillchar

    Arbitrary (auto-converted to string)

    No

    The character that is used for padding. Default value: space.

  • Response

    Returns a new string.

    Note

    If the length of the new string after padding is less than the length of the original string, the original string is returned.

  • Examples

    • Example 1: Pad a string using the asterisks (*).

      • Raw log

        center: this is center
      • Transformation rule

        e_set("str_center", str_center(v("center"), 40, "*"))
      • Result

        center: this is center
        str_center: *************this is center*************
    • Example 2: Pad a string using spaces.

      • Raw log

        center: this is center
      • Transformation rule

        e_set("str_center", str_center(v("center"), 40))
      • Result

        center: this is center
        str_center:              this is center 

str_zfill

The str_zfill function left-pads a string to a specified length with zeros.

  • Syntax

    str_zfill(value, width)
  • Parameters

    Parameter name

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    width

    Number

    Yes

    The length of the string after padding.

  • Response

    Returns a new string.

  • Examples

    • Raw log

      center: this is zfill
    • Transformation rule

      e_set("str_zfill", str_zfill(v("center"), 40))
    • Result

      center:this is zfill
      str_zfill:000000000000000000000000000this is zfill

str_expandtabs

You can replace \t in a string with a space.

  • Syntax

    str_expandtabs(value, tabsize)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    tabsize

    Number

    Yes

    The number of spaces after the conversion.

  • Response

    Returns a new string.

  • Examples

    • Example 1: Convert \t in the logstash field value to spaces.

      • Raw log

        logstash: this is\tstring
      • Transformation rule

        e_set("str_expandtabs", str_expandtabs(v("logstash")))
      • Result

        logstash: this is\tstring
        str_expandtabs: this is string
    • Example 2: Convert \t in the center field value to spaces.

      • Raw log

        {"center": "this is\tstring"}
      • Transformation rule

        e_set("str_expandtabs", str_expandtabs(v("center"), 16))
      • Result

        center: this is\tstring
        str_expandtabs: this is         string

str_ljust

The str_ljust function right-pads a string to a specified length with a specified character.

  • Syntax

    str_ljust(value, width, fillchar)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    width

    Number

    Yes

    The length of the string after padding.

    fillchar

    Arbitrary (auto-converted to string)

    No

    The character that is used for padding. Default value: space.

  • Response

    Returns a new string.

    Note

    If the length of the new string after padding is less than the length of the original string, the original string is returned.

  • Examples

    • Example 1

      • Raw log

        content: this is ljust
      • Transformation rule

        e_set("str_ljust", str_ljust(v("content"), 20, "*"))
      • Result

        content: this is ljust
        str_ljust: this is ljust*******
    • Example 2

      • Raw log

        center: this is ljust
      • Transformation rule

        e_set("str_ljust", str_ljust(v("center"), 20,))
      • Result

        center: this is ljust
        str_ljust: this is ljust   
    • Example 3: If the width is less than or equal to the length of the string, the function returns the original string.

      • Raw log

        center: this is ljust
      • Transformation rule

        e_set("str_ljust", str_ljust(v("center"),10,  "*"))
      • Result

        center: this is ljust
        str_ljust: this is ljust

str_rjust

The str_rjust function left-pads a string to a specified length with a specified character.

  • Syntax

    str_rjust(value, width, fillchar)
  • Parameters

    Parameter

    Data types

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The original string to modify.

    width

    Number

    Yes

    The length of the string after padding.

    fillchar

    Arbitrary (auto-converted to string)

    No

    The character that is used for padding. Default value: space.

  • Response

    Returns a new string.

    Note

    If the length of the new string after padding is less than the length of the original string, the original string is returned.

  • Examples

    • Raw log

      center: this is rjust
    • Transformation rule

      e_set("str_rjust", str_rjust(v("center"), 20, "*"))
    • Result

      center: this is rjust
      str_rjust: *******this is rjust

str_zip

Splits two string values or expressions and merges the results into a single string.

  • Syntax

    str_zip(value1, value2, combine_sep=None, sep=None, quote=None, lparse=None, rparse=None)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value1

    Arbitrary (auto-converted to string)

    Yes

    The value to combine.

    value2

    Arbitrary (auto-converted to string)

    Yes

    The value to combine.

    combine_sep

    Arbitrary (auto-converted to string)

    No

    The identifier that is used to combine the elements. Default value: #.

    sep

    Arbitrary (auto-converted to string)

    No

    The delimiter that is used between the elements after combining. The value must be a single character. Default value: ,.

    quote

    Arbitrary (auto-converted to string)

    No

    The character that is used to enclose the elements after combining. This parameter is required if the values contain delimiters. Default value: ".

    lparse

    Arbitrary (auto-converted to string)

    No

    The delimiter and quote that are used among the elements of value1. Default delimiter: ,. Default quote: ". Format: lparse=(',', '"').

    Note

    The quote has a higher priority than the delimiter.

    rparse

    Arbitrary (auto-converted to string)

    No

    The delimiter and quote that are used among the elements of value2. Default delimiter ,. Default quote: ". Format: rparse=(',', '"').

    Note

    The quote has a higher priority than the delimiter.

  • Response

    A combined string is returned.

  • Examples

    • Example 1

      • Raw log

        website: wwww.aliyun.com
        escape_name: o
      • Transformation rule

        e_set("combine", str_zip(v("website"), v("escape_name"), combine_sep="@"))
      • Result

        website: wwww.aliyun.com
        escape_name: o
        combine: wwww.aliyun.com@o
    • Example 2

      • Raw log

        website: wwww.aliyun.com
        escape_name: o
      • Transformation rule

        e_set("combine", str_zip(v("website"), v("escape_name")))
      • Result

        combine:wwww.aliyun.com#o  
        escape_name:o
        website:wwww.aliyun.com
    • Example 3: Use the sep parameter.

      • Raw log

        f1: a,b,c
        f2: x,y,z
      • Transformation rule

        e_set("combine", str_zip(v("f1"), v("f2"), sep="|"))
      • Result

        f1: a,b,c
        f2: x,y,z
        combine: a#x|b#y|c#z
    • Example 4: Use the quote parameter.

      • Raw log

        f1: "a,a", b, "c,c"
        f2: x, "y,y", z
      • Transformation rule

        e_set("combine", str_zip(v("f1"), v("f2"), quote='|'))
      • Result

        f1: "a,a", b, "c,c"
        f2: x, "y,y", z
        combine: |a,a#x|,|b#y,y|,|c,c#z|
    • Example 5: Use field values whose lengths are different.

      • Raw log

        f1: a,b
        f2: x,y,z
      • Transformation rule

        e_set("combine", str_zip(v("f1"), v("f2")))
      • Result

        f1: a,b
        f2: x,y,z
        combine: a#x,b#y
    • Example 6: Use the lparse and rparse parameters.

      • Raw log

        f1: a#b#c
        f2: x|y|z
      • Transformation rule

        e_set("combine", str_zip(v("f1"), v("f2"), lparse=("#", '"'), rparse=("|", '"')))
      • Result

        f1: a#b#c
        f2: x|y|z
        combine: a#x,b#y,c#z
    • Example 7: Use the lparse and rparse parameters.

      • Raw log

        f1: |a,a|, b, |c,c|
        f2: x, #y,y#, z
      • Transformation rule

        e_set("combine", str_zip(v("f1"), v("f2"), lparse=(",", '|'), rparse=(",", '#')))
      • Result

        f1: |a,a|, b, |c,c|
        f2: x, #y,y#, z
        combine: "a,a#x","b#y,y","c,c#z"

str_isalnum

Checks if a string is alphanumeric.

  • Syntax

    str_isalnum(value)
  • Parameters

    Parameter name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      content: 13
    • Transformation rule

      e_set("str_isalnum", str_isalnum(v("content")))
    • Result

      content: 13
      str_isalnum: True

str_isalpha

Checks whether a string consists of only letters.

  • Syntax

    str_isalpha(value)
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      content: 13
    • Transformation rule

      e_set("str_isalpha", str_isalpha(v("content")))
    • Result

      content: 13
      str_isalpha: False

str_isascii

Determines if the string is ASCII.

  • Syntax

    str_isascii(value)
  • Parameters

    Parameter name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      content: asw123
    • Transformation rule

      e_set("str_isascii", str_isascii(v("content")))
    • Result

      content: asw123
      str_isascii: True

str_isdecimal

Checks whether a string contains only decimal characters.

  • Syntax

    str_isdecimal(value)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Example 1

      • Raw log

        welcome: Hello
      • Transformation rule

        e_set("str_isdecimal", str_isdecimal(v("welcome")))
      • Result

        welcome: Hello
        str_isdecimal: False
    • Example 2

      • Raw log

        num: 123
      • Transformation rule

        e_set("str_isdecimal", str_isdecimal(v("num")))
      • Result

        num: 123
        str_isdecimal: True

str_isdigit

Checks if a string contains only digits.

  • Syntax

    str_isdigit(value)
  • Parameters

    Parameter Name

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      content: 13
    • Transformation rule

      e_set("str_isdigit", str_isdigit(v("content")))
    • Result

      content: 13
      str_isdigit: True

str_isidentifier

Determines whether a string is a valid Python identifier.

  • Syntax

    str_isidentifier(value)
  • Parameters

    Parameter name

    Data Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      class: class
    • Transformation rule

      e_set("str_isidentifier", str_isidentifier(v("class")))
    • Result

      class: class
      str_isidentifier: True

str_islower

Checks if a string contains only lowercase letters.

  • Syntax

    str_islower(value)
  • Parameters

    Parameter

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      lower: asds
    • Transformation rule

      e_set("str_islower", str_islower(v("lower")))
    • Result

      lower: asds
      str_islower: True

str_isnumeric

You can check if a string contains only digits.

  • Syntax

    str_isnumeric(value)
  • Parameters

    Parameter

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      num: 123
    • Transformation rule

      e_set("str_isnumeric", str_isnumeric(v("num")))
    • Result

      num: 123
      str_isnumeric: True

str_isprintable

The str_isprintable function checks whether all characters in a string are printable.

  • Syntax

    str_isprintable(value)
  • Parameters

    Parameter name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      content: vs;,.as
    • Transformation rule

      e_set("str_isprintable",  str_isprintable(v("content")))
    • Result

      content: vs;,.as
      str_isprintable: True

str_isspace

Determines whether a string consists only of space characters.

  • Syntax

    str_isspace(value)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      space:  as afsd
    • Transformation rule

      e_set("str_isspace", str_isspace(v("space")))
    • Result

      space:  as afsd
      str_isspace: False

str_istitle

Checks if the first letter of each word in a string is uppercase and the remaining letters are lowercase.

  • Syntax

    str_istitle(value)
  • Parameters

    Parameter

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      title: Alex Is A Boy
    • Transformation rule

      e_set("str_istitle", str_istitle(v("title")))
    • Result

      str_istitle:true
      title:Alex Is A Boy

str_isupper

Checks whether all letters in the string are uppercase.

  • Syntax

    str_isupper(value)
  • Parameters

    Parameter Name

    Data type

    Required

    Description

    value

    Arbitrary (auto-converted to string)

    Yes

    The string to check.

  • Response

    The value True or False is returned.

  • Examples

    • Raw log

      content: ASSD
    • Transformation rule

      e_set("str_isupper", str_isupper(v("content")))
    • Result

      content: ASSD
      str_isupper: True

str_uuid

Generates a random UUID.

  • Syntax

    str_uuid(lower=True)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    lower

    Boolean

    No

    Specifies whether the letters in the output UUID are in lowercase. Default value: True, which specifies that the letters are in lowercase.

  • Response

    A UUID is returned.

  • Examples

    • Example 1

      • Raw log

        content: I am Iron man
      • Transformation rule

        e_set("UUID", str_uuid())
      • Result

        content: I am Iron man
        UUID: e9fcd6b0-b970-11ec-979d-0f7041e65ab8
    • Example 2

      • Raw log

        content: I am Iron man
      • Transformation rule

        e_set("UUID", str_uuid(lower=False))
      • Result

        content: I am Iron man
        UUID: 0649211E-B971-11EC-A258-E71F0A2930C5