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.
The text to perform manipulations on. All variables can be used in this field.
Text Operation
The manipulation type with the provided 'Text' field. There are several operations to choose from. Below you can find detailed information about each operation and how it can be used.
The Get Length operation allows you to return the length (number of characters) of the text provided.
Examples
Text
Result
Hello World!
12
BotGhost
8
The Character At operation returns the character at the specified index.
Index
The index of the character to retrieve. Indeces start at 0. All variables can be used in this input.
Examples
Text
Index
Result
Hello World!
0
H
Hello World!
1
e
Hello World!
7
o
BotGhost
4
h
The Slice operation allows you to extract text between the start and end indeces. It works similiarly 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. Indeces start at 0. All variables can be used in this input.
Examples
Text
Start Index
End Index
Result
Hello World!
0
7
Hello W
Hello World!
6
11
World
BotGhost
4
8
host
The Substring operation allows you to extract text between the start and end indeces. It works similiarly 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. Indeces start at 0. All variables can be used in this input.
Examples
Text
Start Index
End Index
Result
Hello World
0
7
Hello W
Hello World
6
11
World
BotGhost
4
8
host
The To Uppercase operation converts the provided text to uppercase.
Examples
Text
Result
Hello World
HELLO WORLD
HELLO WORLD!
HELLO WORLD!
botghost
BOTGHOST
The To Uppercase operation converts the provided text to lowercase.
Examples
Text
Result
Hello World
hello world
HELLO WORLD!
hello world!
botghost
botghost
The trim operation allows you to remove whitespaces from the start and end of the provided text.
Examples
Text
Result
Hello World
Hello World
Hello World
Hello World
BotGhost
BotGhost
The Replace operation replaces a portion of text in the text you provided with some other text. Only the first match will get replaced.
Search
The portion of text that must be replaced in the text. All variables can be used in this input.
Replacement
The portion of text to replace with. All variables can be used in this input.
Examples
Text
Search
Replacement
Hello World!
World
everyone
Hello everyone!
Hello World!
BotGhost
Hello BotGhost World!
Cats are cute
C
R
Rats are cute
The replace all operation allows you to replace all matching portions of text in the text you provided with some other text.
Search
The portion of text that must be replaced in the text. All variables can be used in this input.
Replacement
The portion of text to replace with. All variables can be used in this input.
Examples
Text
Search
Replacement
Result
Hello World
World
everyone
Hello everyone!
you are smart, aren't you?
you
we
we are smart, aren't we?
Bitter
t
l
Biller
The Starts With operation checks if a text starts with a specific portion of text. It returns true when it does, false when it doesn't.
Search
The substring that must be compared with the text. All variables can be used in this input.
Examples
Text
Search
Result
Hello World
He
true
Hello World
World
false
Hello World
BotGhost
false
The Ends With operation checks if a text ends with a specific portion of text. It returns true when it does, false when it doesn't.
Search
The substring that must be compared with the text. All variables can be used in this input.
Examples
Text
Search
Result
Hello World
World
true
Hello World
He
false
Hello World
BotGhost
false
The Includes operation checks if a text contains a specific portion of text. It returns true when it does, false when it doesn't.
Search
The substring that must be compared with the text. All variables can be used in this input.
Examples
Text
Search
Result
Hello World
World
true
Hello World
lo Wor
true
Hello World
o
true
Hello World
BotGhost
false
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 portion of text that must be searched in the text. All variables can be used in this input.
Examples
Text
Search
Result
Hello World!
e
1
Hello World!
World
6
Hello World!
BotGhost
-1
yes, goodbye
ye
0
The Last Index Of operation returns the index of the last 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 portion of text that must be searched in the text. All variables can be used in this input.
Examples
Text
Search
Result
Hello World!
e
1
Hello World!
World
10
Hello World!
BotGhost
-1
yes, goodbye
ye
2
The Split operation splits the text into an array of portions of text basing on the given delimiter.
Search
The portion of text that must be used as a delimiter. All variables can be used in this input.
Examples
Text
Search
Result
20/04/2024
/
20,4,2024
docs.botghost.com
.
docs,botghost,com
Hello everyone!
c
Hello everyone!
The Match operation searches for a pattern using regex and returns all matches as an array. If no matches are found, null is returned.
Search
The regex pattern to search for.
Examples
Text
Search
Result
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
The Search operation searches for a pattern using regex and returns the index of the first match. If no matches are found, -1 is returned.
Search
The regex pattern to search for.
Examples
Text
Search
Result
API Requests are Good
[A-Z]
0
This is a test, using regex to find the word test in a sentence.
\btest\b
10
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
-1
The repeat operation repeats the given text for the specified amount of times.
Count
The number of times to repeat the text. All variables can be used in this input.
Examples
Text
Count
Result
ah
5
ahahahahah
Hello!
2
Hello! Hello!
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. There's also an option that excludes quotes (") around the text.
Examples
Text
Result
Hello "World"!
"Hello \"World\"!"
Line
Break
"Line\nBreak"
Not a line break \n
"Not a line break \\n"
Examples - No Enclosing Quotes
Text
Result
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 set the name of the variable that can be used anywhere to retrieve the result of the operation. Make sure that the name of the variable does not correspond to the name of a default variable or of an another action.
You can copy the variable by clicking the clipboard icon in the section right below the optional variable field.