Built-in functions: string

Built-in functions: String

@split <delimiter>, <string>

Splits the string into an array using the specified delimiter.

Alias: @explode

“,” @split “a,b,c” // result: [ a, b, c ]

@length <string>

Returns the length of a string.

@length abc

> 3

@substr <string>, <start>, <length>

Returns a substring from the given string.

$a: @substr “abcde”, 1, 3

@echo $a

> bcd

@str_pos <haystack>, <needle>

Returns the position of the first occurrence of a substring.

@strpos abcbdbe, b // return 1

@str_m_pos <haystack>, <needle>

Returns all matched positions (case-sensitive).

@strpos abcbdbe, b // return [1,3,5]

@str_i_pos <haystack>, <needle>

Returns the first position of a substring (case-insensitive).

@strpos abcbdbe, B // return 1

@str_m_i_pos <haystack>, <needle>

Returns all positions of needle in haystack (case-insensitive).

@strpos abcbdbe, B // return [1,3,5]

@str_to_lower <string>

Converts the string to lowercase.

@str_to_lower Hello World // return “hello world”

@str_to_upper <string>

Converts the string to uppercase.

@str_to_lower Hello World // return “HELLO WORLD”