Text Splitting
In this section, you’ll learn how to use the text splitting.
Content
Functions Used > $textSplit[] > $splitText[] > $getTextSplitLength > $getTextSplitIndex[] > $joinSplitText[] > $removeSplitTextElement[] > Simple Code
Functions Used
$textSplit[]
$splitText[]
$getTextSplitLength
$getTextSplitIndex[]
$joinSplitText[]
$removeSplitTextElement[]
$editSplitText[]
$textSplit
Splits the provided text by a given separator and saves the value temporarily.
Syntax
$textSplit[Text;Separator]
Parameters
Text
(Type: String || Flag: Emptiable)
: The text to split.Separator
(Type: String || Flag: Emptiable)
: The separator to split the text with. If this parameter is empty, it separates the text by each character.
Example
$nomention
$textSplit[hello-world-!;-]
> $splitText[2]
$splitText
Each separated text has a number, i.e. an index. $splitText
is a function that returns one of the elements of the separated text by an index or the sign <
- the very first element, or >
- the very last element.
Syntax
$splitText[Index]
Parameters
Index
(Type: HowMany || Flag: Required)
: The split value to get (e.g.2
for the second split). You can also use>
to return the last split value i.e$splitText[>]
.
Example
$nomention
$textSplit[hello world !; ]
> $splitText[<]
> $splitText[2]
> $splitText[>]
world
!
$getTextSplitLength
Returns the number of splits.
Syntax
$getTextSplitLength
Example
$nomention
$textSplit[hello%world%!;%]
> $getTextSplitLength
$getTextSplitIndex
Retrieves index from the provided value. Returns -1
if it couldn’t find the value.
Syntax
$getTextSplitIndex[Value]
Parameters
Value
(Type: String || Flag: Emptiable)
: The value to search in the text split.
Example
$nomention
$textSplit[hello_world_!;_]
> $getTextSplitIndex[$message]
$joinSplitText
This function returns the current elements of the separated text with the specified (sometimes new) separator.
Syntax
$joinSplitText[Separator]
Parameters
Separator
(Type: String || Flag: Emptiable)
: The separator to be put between the text split values.
Example
$nomention
$textSplit[hello#world#!;#]
> $joinSplitText[
> ]
world
!
$removeSplitTextElement
This function removes an element from the separated text by the specified index.
Syntax
$removeSplitTextElement[Index]
Parameters
Index
(Type: Integer || Flag: Required)
: The index of the$textSplit[]
value to remove.
Example
$nomention
$textSplit[hello-world-!;-]
$removeSplitTextElement[3]
> $joinSplitText[-]
$editSplitText
This function replaces the element at the specified index with a new element instead of the previous one.
Syntax
$editSplitText[Index;Value]
Parameters
Index
(Type: Integer || Flag: Required)
: The index of the element to edit.Value
(Type: String || Flag: Required)
: The new value to assign to the provided index.
Example
$nomention
$textSplit[hello-world-!;-]
$editSplitText[2;bdfd]
> $joinSplitText[-]
Simple Code
$nomention
$textSplit[$message;]
Characters: $getTextSplitLength
$textSplit[$message; ]
Words: $getTextSplitLength
Random word: $splitText[$random[1;$sum[$getTextSplitLength;1]]]
First word: $splitText[<]
Words: 2
Random word: world!
First word: Hello