BotGhost Documentation
Support ServerYouTubeMarketplaceBotGhost PremiumSign in
  • Welcome to BotGhost
  • Guidelines & Privacy
  • Changelogs 2025
    • Changelogs 2024
    • Changelogs 2023
  • BotPanel Documentation
  • Getting Started
    • Create Your First Bot
      • Create Your Second Bot
    • Invite Your Bot
    • Standard Practices
      • Advanced Practices
    • Mobile Application (PWA)
  • Support
    • BotGhost Support
    • Frequently Asked Questions
  • Premium & Priority Hosting
    • Priority Hosting
    • Our Premium Features
    • Plans & Payment Methods
    • Manage Your Subscription
    • Upgrade Your Bot
    • Refund & Cancellation Policy
    • Beta Features
  • General Settings and Collaboration
    • Settings
    • Collab
    • Status
    • Active Developer Badge
    • Marketplace
  • Custom Commands & Events
    • Command & Event Builder
      • Sharing Commands and Events
      • Advanced Options
    • Actions
      • Message Actions
        • Send or Edit a Message
          • Button
          • Select Menu
        • Edit a Button or Select Menu
        • Send a Form
        • Delete a Message
        • Publish a Message
        • React to a Message
        • Pin a Message
      • Custom Variable Actions
        • Set Variable
        • Run Equation on Variable
        • Delete Variable
      • API Actions
        • Send an API Request
        • Execute an IFTTT Trigger
      • Loop Actions
        • Run a Loop
        • Stop a Loop
      • Voice Actions
        • Join a Voice Channel
        • Leave a Voice Channel
        • Voice Move a Member
        • Voice Kick a Member
        • Voice Mute or Unmute a Member
        • Voice Deafen or Undeafen a Member
      • Role Actions
        • Add Roles
        • Remove Roles
        • Create a role
        • Delete a role
        • Edit Role
      • Channel Actions
        • Create a channel
        • Edit a channel
        • Delete a channel
      • Thread and Forum Actions
        • Create a Thread
        • Edit a Thread
        • Delete a Thread
      • Server Actions
        • Kick a member
        • Ban a member
        • Timeout a member
        • Change a members nickname
        • Purge Messages
        • Create Server Invite
      • Other Actions
        • Wait before running another action
        • Manipulate some text
        • Send an error log message
        • Set a unique variable
        • Change the Bot's Status
        • Note
      • [LEGACY] Reply Actions
        • Plain Text Reply
        • Embed Reply
        • Random Reply
        • Send a message to a channel
        • Direct Message a User
        • Send a Message with attached buttons
          • Buttons
        • Send a message with a select menu
          • Menu Option
    • Conditions
      • Comparison Condition
      • Permission Condition
      • Chance Condition
      • Channel Condition
      • Role Condition
      • User Condition
      • Premium Check Condition
    • Options
      • Text Option
      • Number Option
      • User Option
      • Channel Option
      • Role Option
      • Choice Option
      • Attachment Option
    • Events
      • Timed Events
      • Webhooks
    • Data Storage
      • Collections
      • Objects
    • IFTTT
    • Variables
  • Server Management
    • Moderation
    • Discord Automod
    • Tickets
    • Welcomer
    • Verification
    • Statistic Channels
    • Modmail
    • Auto-React
    • Sticky Roles
    • Emoji Manager
    • Polls Filter
    • Automod
    • Logging
  • Messages
    • Timed Messages
    • Reaction Roles
    • Autoresponder
    • Embed Builder
    • Sticky Messages
    • Polls
    • Global Chat
    • Media Channels
  • AI
    • ChatGPT
    • Image Generation
  • Game Integrations
    • Roblox Verification
  • Social Integrations
    • YouTube
    • Twitch
  • Community Engagement
    • Leveling
    • Temp Voice Channels
    • Suggestions
    • Invite Tracker
    • Starboard
    • Question Of The Day
    • Giveaways
  • Fun Modules
    • Economy & Minigames
    • Birthdays
    • Counting
  • Utility
    • Translation
    • Weather
Powered by GitBook
On this page
  • Text
  • Text Operation
  • Variable

Was this helpful?

  1. Custom Commands & Events
  2. Actions
  3. Other Actions

Manipulate some text

Last updated 7 months ago

Was this helpful?

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.

Operation
Information

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

Text
Result

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

Text
Index
Result

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

Text
Search
Result

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

Text
Search
Result

Hello World!

o

7

Hello World!

Hello

0

Hello World!

BotGhost

-1

BotGhost is cool, isn't it?

is

18

Operation
Information

Returns an extracted portion of text.

Returns an extracted portion of text.


Substring

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

Text
Start Index
End Index
Result

Hello World

0

7

Hello W

Hello World

6

11

World

BotGhost

4

8

host


Slice

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

Text
Start Index
End Index
Result

Hello World!

0

7

Hello W

Hello World!

6

11

World

BotGhost

4

8

host

Operation
Information

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

Text
Result

Hello World

HELLO WORLD

HELLO WORLD!

HELLO WORLD!

botghost

BOTGHOST


To Lowercase

The To Lowercase operation converts the provided text to lowercase.

Examples

Text
Result

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

Text
Result

Hello World

Hello World

Hello World

Hello World

BotGhost

BotGhost

Operation
Information

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

Text
Search
Result

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

Text
Search
Result

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

Text
Search
Result

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

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


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

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

Operation
Information

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

Text
Search
Replacement

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

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


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

Text
Search
Result

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

Text
Count
Result

ah

5

ahahahahah

Hello!

2

Hello! Hello!

Operation
Information

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

Text
Result

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

Text
Result

Hello "World"!

Hello \"World\"!

Line Break

Line\nBreak

Not a line break \n

Not a line break \\n

Variable

If the variable used in this field already has a value, the previous value will be overwritten and cannot be accessed again.

You can see a list of string methods in the action, or .

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 .

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 .

Regular expressions can be a tricky concept and take practice. Before using this operation, it's advised to check out other resources like and to learn more and experiment with regular expressions. You can also use the ChatGPT module or other AI websites to generate regex patterns for you, but they may not always be accurate.

Regular expressions can be a tricky concept and take practice. Before using this operation, it's advised to check out other resources like and to learn more and experiment with regular expressions. You can also use the ChatGPT module or other AI websites to generate regex patterns for you, but they may not always be accurate.

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 . You can use the clipboard icon under Result Variable to copy this variable to your device's clipboard.

view more detailed descriptions
here
here
Regex101
MDN Web Documentation
Regex101
MDN Web Documentation
command or event
Get Length
Character At
Index Of
Last Index Of
Replace
Replace All
Split
Repeat
Substring
Slice
To Uppercase
To Lowercase
Trim
Includes
Starts With
Ends With
Match
Search
JSON Stringify
JSON Stringify (No Enclosing Quotes)
Manipulate some text Action Block
Text Parameter of the Manipulate some text block
Text Operation - Index of the Manipulate some text block
Text Operation - Start Index and End Index of the Manipulate some text block
Text Operation - Start Index and End Index of the Manipulate some text block
Text Operation - Search of the Manipulate some text block
Text Operation - Replacement of the Manipulate some text block
Text Operation - Search of the Manipulate some text block
Text Operation - Replacement of the Manipulate some text block