Skip to content

String

An immutable sequence of Unicode characters.

Static Methods

format_time

navi
String.format_time(
    time: int,
    format: String,
    timezone: String = symbol_info.timezone
  ): String

Formats a timestamp (in milliseconds since epoch) into a String based on the provided format and timezone.

Parameters

NameTypeDefaultDescription
timeintThe timestamp in milliseconds since epoch to format.
formatStringThe format String for the conversion.
timezoneStringsymbol_info.timezoneThe timezone to use for formatting.

Returns: String


from

Converts a value to its String representation.

Parameters

NameTypeDefaultDescription
valueintThe integer value to convert.
formatStringThe format String for the conversion.

Returns: String

Converts a float to String with the given format.

Parameters

NameTypeDefaultDescription
valuefloatThe float value to convert.
formatStringThe format String for the conversion.

Returns: String

Converts an integer to String using a Format constant.

Parameters

NameTypeDefaultDescription
valueintThe integer value to convert.
formatFormatThe Format constant controlling formatting.

Returns: String

Converts a float to String using a Format constant.

Parameters

NameTypeDefaultDescription
valuefloatThe float value to convert.
formatFormatThe Format constant controlling formatting.

Returns: String

Converts any value to its String representation.

Parameters

NameTypeDefaultDescription
valueTThe value to convert to String.

Returns: String

Methods

contains

navi
String.contains(self: String, str: String): bool

Checks if the String contains the specified substring.

Parameters

NameTypeDefaultDescription
selfString
strStringThe substring to search for.

Returns: bool


ends_with

navi
String.ends_with(self: String, str: String): bool

Checks if the String ends with the specified suffix.

Parameters

NameTypeDefaultDescription
selfString
strStringThe suffix to search for.

Returns: bool


format

navi
String.format(self: String, values: any): String

Formats the String as a template, substituting {} placeholders with the provided values.

Parameters

NameTypeDefaultDescription
selfString
valuesanyVariable number of values to substitute into the template.

Returns: String


index_of

navi
String.index_of(self: String, str: String): int

Returns the zero-based index of the first occurrence of a substring, or na if not found.

Parameters

NameTypeDefaultDescription
selfString
strStringThe substring to search for.

Returns: int


length

navi
String.length(self: String): int

Returns the length of the String.

Parameters

NameTypeDefaultDescription
selfString

Returns: int


lower

navi
String.lower(self: String): String

Converts all characters in the String to lowercase.

Parameters

NameTypeDefaultDescription
selfString

Returns: String


match

navi
String.match(self: String, regex: String): String

Returns the matched substring if the String matches a regex pattern, or an empty String otherwise.

Parameters

NameTypeDefaultDescription
selfString
regexStringThe regular expression pattern to match.

Returns: String


pad_end

navi
String.pad_end(self: String, len: int, fill: String = " "): String

Right-pads the String with fill until it reaches at least len characters.

Parameters

NameTypeDefaultDescription
selfString
lenintThe minimum target length in characters.
fillString" "The padding String. Defaults to " ".

Returns: String


pad_start

navi
String.pad_start(self: String, len: int, fill: String = " "): String

Left-pads the String with fill until it reaches at least len characters.

Parameters

NameTypeDefaultDescription
selfString
lenintThe minimum target length in characters.
fillString" "The padding String. Defaults to " ".

Returns: String


repeat

navi
String.repeat(self: String, repeat: int): String

Returns a new String consisting of the String repeated a specified number of times.

Parameters

NameTypeDefaultDescription
selfString
repeatintThe number of times to repeat the String.

Returns: String


replace

navi
String.replace(
    self: String,
    target: String,
    replacement: String,
    occurrence: int = 0
  ): String

Replaces the N-th occurrence of a target substring with a replacement.

Parameters

NameTypeDefaultDescription
selfString
targetStringThe substring to be replaced.
replacementStringThe replacement substring.
occurrenceint0N-th occurrence to replace (0-indexed). Defaults to 0.

Returns: String


replace_all

navi
String.replace_all(self: String, target: String, replacement: String): String

Replaces all occurrences of a target substring with a replacement.

Parameters

NameTypeDefaultDescription
selfString
targetStringThe substring to be replaced.
replacementStringThe replacement substring.

Returns: String


split

navi
String.split(self: String, separator: String): Array<String>

Splits the String into an array of substrings based on a separator.

Parameters

NameTypeDefaultDescription
selfString
separatorStringThe separator String to split on.

Returns: Array<String>


starts_with

navi
String.starts_with(self: String, str: String): bool

Checks if the String starts with the specified prefix.

Parameters

NameTypeDefaultDescription
selfString
strStringThe prefix to search for.

Returns: bool


substring

navi
String.substring(self: String, begin_pos: int, end_pos: int): String

Returns a substring from begin_pos to end_pos (exclusive).

Parameters

NameTypeDefaultDescription
selfString
begin_posintThe starting position (inclusive).
end_posintThe ending position (exclusive).

Returns: String


to_number

navi
String.to_number(self: String): float

Converts the String to a floating-point number.

Parameters

NameTypeDefaultDescription
selfString

Returns: float — The parsed float value, or na if the String cannot be parsed.


trim

navi
String.trim(self: String): String

Trims leading and trailing whitespace from the String.

Parameters

NameTypeDefaultDescription
selfString

Returns: String


trim_end

navi
String.trim_end(self: String): String

Trims trailing whitespace from the String.

Parameters

NameTypeDefaultDescription
selfString

Returns: String


trim_start

navi
String.trim_start(self: String): String

Trims leading whitespace from the String.

Parameters

NameTypeDefaultDescription
selfString

Returns: String


upper

navi
String.upper(self: String): String

Converts all characters in the String to uppercase.

Parameters

NameTypeDefaultDescription
selfString

Returns: String