Manipulate some text

With the 'Manipulate some text' block you are able to provide a text and perform text operations like getting the length of the text, trimming text or checking if the text starts or ends with another string.
Text
The text to perform manipulations on. All Variables can be used in this field.

Text Operation
The type of text manipulation to perform on the provided Text string. There are several operations to choose from. Below you can find detailed information about each operation and how it can be used.
Returns the number of characters in the string.
Returns the character at the position of the specified index in the string.
Returns the index position of the first appearance of a specified query in the string.
Returns the index position of the last appearance of a specified query in the string.
Get Length
The Get Length operation allows you to return the number of characters of the text provided.
Examples
Hello World!
12
BotGhost
8
Character At
The Character At operation returns the character at the specified index.
Index
The position of the character in the string that you'd like to return. Indexes start at 0. All Variables can be used in this input.

Examples
Hello World!
0
H
Hello World!
1
e
Hello World!
7
o
BotGhost
4
h
Index Of
The Index Of operation returns the index of the first character of the given portion of text. If there are multiple matches, the first match is returned. If there are no matches, -1 is returned.
Search
The text to find the index of. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World!
e
1
Hello World!
World
6
Hello World!
BotGhost
-1
yes, goodbye
ye
0
Last Index Of
The Last Index Of operation returns the index of the first character of the given portion of text. If there are multiple matches, the last match is returned. If there are no matches, -1 is returned.
Search
The text to find the last index of. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World!
o
7
Hello World!
Hello
0
Hello World!
BotGhost
-1
BotGhost is cool, isn't it?
is
18
Substring
The Substring operation allows you to extract text between the start and end indexes. It works similarly to the Slice operation. You can learn more about the differences between the Slice and Substring operations here.
Start Index and End Index
The character index to start extraction from and the character index to end extraction at. The end index represents the index of the first character that should not be included. Indexes start at 0. All variables can be used in this input.

Examples
Hello World
0
7
Hello W
Hello World
6
11
World
BotGhost
4
8
host
Slice
The Slice operation allows you to extract text between the start and end indexes. It works similarly to the Substring operation. You can learn more about the differences between the Slice and Substring operations here.
Start Index and End Index
The character index to start extraction from and the character index to end extraction at. The end index represents the index of the first character that should not be included. Indexes start at 0. All variables can be used in this input.

Examples
Hello World!
0
7
Hello W
Hello World!
6
11
World
BotGhost
4
8
host
Returns the text with all letter characters displaying in uppercase.
Returns the text with all letter characters displaying in lowercase.
Returns the text with no space characters ( ) at the start or end of the string.
To Uppercase
The To Uppercase operation converts the provided text to uppercase.
Examples
Hello World
HELLO WORLD
HELLO WORLD!
HELLO WORLD!
botghost
BOTGHOST
To Lowercase
The To Lowercase operation converts the provided text to lowercase.
Examples
Hello World
hello world
HELLO WORLD!
hello world!
botghost
botghost
Trim
The trim operation allows you to remove whitespaces from the start and end of the provided text.
Examples
Hello World
Hello World
Hello World
Hello World
BotGhost
BotGhost
Returns true or false based on if the text includes a string.
Returns true or false based on if the text starts with a string.
Returns true or false based on if the text ends with a string.
Returns matches based on regular expressions.
Returns indexes based on regular expressions.
Includes
The Includes operation checks if your string contains a specific portion of text. It returns true when it does, and false when it doesn't. You can alternatively use the contains comparison type in the Comparison Condition block.
Search
The text that is compared to the original string. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World
World
true
Hello World
lo Wor
true
Hello World
o
true
Hello World
BotGhost
false
Starts With
The Starts With operation checks if your string starts with a specific portion of text. It returns true when it does, and false when it doesn't. You can alternatively use the starts with comparison type in the Comparison Condition block.
Search
The text that is compared at the start of the original string. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World
He
true
Hello World
World
false
Hello World
BotGhost
false
Ends With
The Ends With operation checks if your string ends with a specific portion of text. It returns true when it does, and false when it doesn't. You can alternatively use the ends with comparison type in the Comparison Condition block.
Search
The text that is compared at the end of the original string. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World
World
true
Hello World
He
false
Hello World
BotGhost
false
Match
The Match operation will return the first match from a regular expression (regex) pattern. If there are any capturing groups, it will return them after the match, separated by commas. The variable can also be used as an array when surrounded with the [] brackets.
Search
The regular expression pattern to search for. This input is case sensitive. All Variables can be used.

Examples
API Requests are Good
[A-Z]
A,P,I,R,G
This is a test, using regex to find the word test in a sentence.
\btest\b
test,test
This is a test to find numbers in a sentence. Since there are no numbers here, it will not return any matches
\b\d+\b
null
Search
The Search operation will return the index of the first match from a regular expression (regex) pattern.
Search
The regular expression pattern to search for. This input is case sensitive. All Variables can be used.

Example
API Requests are Good
[A-Z]
A,P,I,R,G
This is a test, using regex to find the word test in a sentence.
\btest\b
test,test
This is a test to find numbers in a sentence. Since there are no numbers here, it will not return any matches
\b\d+\b
null
Returns the original text with a portion of it replaced.
Returns the original text with portions of it replaced.
Returns the original text divided into an array.
Returns the original text a specified number of times.
Replace
The Replace operation replaces the first occurrence of a substring from the original text with another string you've specified.
Search
The portion of text that must be replaced in the text. This input is case sensitive. All Variables can be used in this input.

Replacement
The portion of text to replace with. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World!
World
everyone
Hello everyone!
Hello World!
BotGhost
Hello BotGhost World!
Cats are cute
C
R
Rats are cute
Replace All
The Replace All operation replaces all occurrences of a substring from the original text with another string you've specified.
Search
The portion of text that must be replaced in the text. This input is case sensitive. All Variables can be used in this input.

Replacement
The portion of text to replace with. This input is case sensitive. All Variables can be used in this input.

Examples
Hello World
World
everyone
Hello everyone!
you are smart, aren't you?
you
we
we are smart, aren't we?
Bitter
t
l
Biller
Split
The Split operation separates your string with commas based on a delimeter. The variable can also be used as an array when surrounded with the [] brackets.
Search
The text that your string will be split around. This input is case sensitive. All Variables can be used.

Examples
20/04/2024
/
20,4,2024
docs.botghost.com
.
docs,botghost,com
Hello everyone!
c
Hello everyone!
Repeat
The Repeat operation duplicates your string a specified number of times.
Count
The number of times your string will appear. All Variables can be used in this input.

Examples
ah
5
ahahahahah
Hello!
2
Hello! Hello!
Returns the original text surrounded by quotes (") with escaped quotes and line breaks.
Returns the original text with escaped quotes and line breaks.
JSON Stringify
The JSON Stringify operation allows you to automatically manipulate and escape quotes and line breaks in the given text for it to work in the Send an API Request action. The result will include quotes (") around the text.
Examples
Hello "World"!
"Hello \"World\"!"
Line Break
"Line\nBreak"
Not a line break \n
"Not a line break \\n"
JSON Stringify (No Enclosing Quotes)
The JSON Stringify (No Enclosing Quotes) operation allows you to automatically manipulate and escape quotes and line breaks in the given text for it to work in the Send an API Request action. The result will not include quotes (") around the text.
Examples
Hello "World"!
Hello \"World\"!
Line Break
Line\nBreak
Not a line break \n
Not a line break \\n
Variable

The Variable field allows you to name the variable that can be used in other Actions and Conditions that follow this action block in the same command or event. You can use the clipboard icon under Result Variable to copy this variable to your device's clipboard.
Last updated
Was this helpful?