2.9.2 String Functions

Examples with var str="hello, world" executed;

Function

Description

Example of usage

Result

bin(a)

Returns the string of number a in binary representation

bin(0b0010)

"10"

chr(a)

Returns the character with a of the ASCII code in string type

chr(65)

"A"

double(s)

Returns the real number type value of the real number string s (Interpret only up to the position where interpretation is possible, and discard the rest.)

double("29.38E-2")

0.2938

hex(a)

Returns the string of number a in hexadecimal representation

hex(0x7A2F)

"7A2F"

int(s)

Returns the integer type value of the integer string s (Interpret only up to the position where interpretation is possible, and discard the rest.)

int("13.25")

int("29.38E-2")

13

29

left(s, n)

Returns a string of the first n characters of the string s

left(str, 3)

"hel"

len(s)

Returns the length of the string if s is a string and returns the number of elements in the array if s is an array

len("HELLO")

len([20, 30, 80])

5

3

mid(s, i, n)

Returns a string of n characters starting from the i-th character of the string s (The position of the first character is 0.)

mid(str, 3, 5)

"lo, w"

mirror(s)

Returns the string inverted from the string s

mirror("HELLO")

"OLLEH"

right(s, n)

Returns a string of the last n characters of the string s

right(str, 3)

"rld"

str(a)

Returns a string of number a in decimal representation

str(13.25)

13.250000

strops(s, p)

Returns the first position in the string s that matches the string p (The first character position will be 0 or -1 if there is none.)

strpos(str, "llo")

strpos(str, "hi")

2

-1

Last updated

Was this helpful?