Strings

Edit

Introduction #

String in a programming language is a sequence of characters. It is used to represent text rather than numbers.
Strings are contained within a pair of double quotes, i.e. "Cat" or "Hello World".
Strings can contain numbers, however you must realize that "5" doesn’t have the value of 5, it has the value of 0, the same as "a" does.
You cannot add strings either, i.e. "12" + "34" isn’t "46", it’s "1234". 12 + 34 is 46.
If you wish to convert a string to a number, you can use String to Number command.


Edit

String Position #

Returns the position of the first occurrence of a specified value in a string.
Returns 0 if it doesn’t find any match.

Box Name Type Description
Save Variable As String Variable name to save the position
String (text) String String to search inside of
String To Search For String Value to search for
Search From Position number What position in the string to start the search at, default is 0
Case Insensitive Checkbox If this is checked, it will return the first matching value, regardless of case.
Value to search for String From Location Case Insensitive Position returned
hello hello and hello world 0 Unchecked 1
hello Hello and hello world 0 Unchecked 11
hello Hello and hello world 0 Checked 1
hello Hello and Hello world 0 Unchecked 0
hello Hello and Hello world 0 Checked 1
hello hello and hello world 5 Unchecked 11 (finds the second hello since we’re searching from the 5th letter in the string)

Edit

String Get Length #

Returns the length (the amount of characters) of a string.

Box Name Type Description
Save Variable As String Variable name to save returned value.
String (text) String String to get the length of.
String Length returned
Hello 5
”” 0

Edit

String Count #

Returns the number of occurrences of a character/string within a string.

Box Name Type Description
Save Variable As String Variable name to save result.
String (text) String String to look at
Character/String To Count String Specify a single character or a string you want to count inside the specified string
Case Insensitive Checkbox If this is checked, it will count all characters regardless of case
Value to search for String Case Insensitive Result
Ab AbAbabAb Unchecked 3
Ab AbAbabAb Checked 4
33 333 and 33 and 33333 Unchecked 7
black Mr.Black has a black car and a black cat. Unchecked 2
black Mr.Black has a black car and a black cat. Checked 3

Edit

String Clamp #

Extracts a part of a string and returns the extracted part.
You need to specify the index of the first character and the amount of characters to extract.

Box Name Type Description
Save Variable As String Variable name to save the clamped string.
String (text) String String (text) to clamp
Start Position Int Where to start the clamp (first character = 0)
Amount of Characters Int Amount of characters to include in the clamp
Original string Start Amount Result
Hello World! 1 5 Hello
This is cool! 9 4 cool

Edit

String Remove Section #

Removes a part of a string and returns the remaining string. This is the opposite of String Clamp.
You need to specify the starting position and amount of characters to remove.

Box Name Type Description
Save Variable As String Variable name to save the clamped string.
String (text) String String to remove it from
Start Position Int Where to start the removal
Amount of Characters Int Amount of characters to remove
Original string Start Amount Result
Hello World! 6 10 Hello
Hello World! This is a nice day. 6 6 Hello! This is a nice day.
Lioran and Sebas is cool! 1 11 Sebas is cool!

Edit

String Trim #

Trims blank spaces or specific characters from your string.

Box Name Type Description
Save Variable As String Variable name to save the trimmed string.
String (text) String String to be trimmed. This is case sensitive
Strings to Delete String If left blank, will delete all spaces before and after the string. If specific characters like @, # or ! are to be trimmed, use the | delimiter.
Original string String to delete Result
!shoutout @Sebas !|@ shoutout Sebas
!shoutout @Sebas !|@seb shoutout @Sebas
!shoutout @Sebas !|@Seb shoutout as
!shoutout \Sebas !|\\ shoutout Sebas

Edit

String Replace All #

Searches a string for a specified value and replaces it with another specified string.
All occurrences will be replaced.

Box Name Type Description
Save Variable As String Variable name to save the string.
String (text) String String to look into
Replace This String The value to search for to be replaced
With This String The value to replace the search value with. Can be empty to completely remove it.
Case Insensitive Checkbox If this is checked, it will replace all the matching values, regardless of case
Value to search for Value to replace it with String Case Insensitive Result
l / Hello Unchecked He//o
  - Hello World and Hello World Unchecked Hello-World-and-Hello-World
hello goodbye Hello and hello and hello Unchecked Hello and goodbye and goodbye
hello goodbye Hello and hello and hello Checked goodbye and goodbye and goodbye

Edit

String Replace #

Searches a string for a specified value and replaces it with another specified string.
Only the first occurrence will be replaced.

Box Name Type Description
Save Variable As String Variable name to save the string.
String String String to look into
Replace this String The value to search for to be replaced
With this String The value to replace the search value with. Can be empty to completely remove it.
Case Insensitive Checkbox If this is checked, it will replace the first matching value, regardless of case.
Value to search for Value to replace it with String Case Insensitive Result
l / Hello Unchecked He/lo
  - Hello World and Hello World Unchecked Hello-World and Hello World
hello goodbye Hello and hello and hello Unchecked Hello and goodbye and hello
hello goodbye Hello and hello and hello Checked goodbye and hello and hello

Edit

String Lower Case #

Converts a string to lowercase letters.

Box Name Type Description
Save Variable As String Variable name to save the converted string.
String (text) String to convert to lower case letters  
Original String Returned String
HELLO World hello world

Edit

String Upper Case #

Converts a string to uppercase letters.

Box Name Type Description
Save Variable As String Variable name to save the converted string.
String (text) String String to convert to upper case letters.
Original String Returned String
hello world HELLO WORLD

Edit

String Capitalize #

Converts the first character in a string to uppercase.

Box Name Type Description
Save Variable As String Variable name to save the converted string.
String (text) String String to convert first character to uppercase.
Original String Returned String
hello world Hello world

Edit

String Letters & Digits Only #

Removes all symbols from a string (including spaces), leaving only letters and digits.

Box Name Type Description
Save Variable As String Variable name to save the converted string.
String (text) String The string (text) to remove the symbols from.
Original String Processed String
!Hello123@ Hello123
$12.50 12.50
Hi! How are you? HiHowareyou

Edit

String Digits Only #

Removes all letters and special symbols from a string (including spaces), leaving only digits.

Box Name Type Description
Save Variable As String Variable name to save the converted string.
String (text) String The string (text) to remove the letters and special symbols from.
Original String Processed String
Hello  
1a2b3c 123
$12.50 12.50

Edit

String Letters Only #

Removes all digits and special symbols from a string (including spaces), leaving only letters.

Box Name Type Description
Save Variable As String Variable name to save the converted string.
String (text) String String to remove all digits and symbols from.
Original String Processed String
!Hello123@ Hello
$12.50 USD USD
12345  
Hi! How are you? HiHowareyou

Edit

String Format #

Divides a string into multiple lines.
Very useful command to use together with Math: Trigger Pull for Bits or Redeem points with a message. You can force the viewer’s message to be split into multiple lines in your Text GDI+ source.

Box Name Type Description
Save Variable As String Variable name to save the formatted string
String (text) String The string (text) to format.
Character Per Line String The maximum amount of characters per line.
Min. Cutoff Length String The minimum amount of letters a word should be before allowing it to be cut it in the middle.

Edit

String Hash #

Hashes a string using one of the selected algorithms.

Hashing is a cryptographic process that can be used to validate the authenticity and integrity of various types of input. It is widely used in authentication systems to avoid storing plaintext passwords in databases, but is also used to validate files, documents and other types of data.
You can read more about hashing in this article.

Box Name Type Description
Text String String to hash
Save Variable As String Variable to save the result
Type Dropdown menu Select which algorithm to use to hash

Edit

String Substitute Variables #

Replaces substituted variable placeholders (ex: /$username$/) in a template string with variables from the current button, or a provided object.

Box Name Type Description
Template String Variable String Variable name containing a template string with substituted variable placeholders
Replacement Object Name Object If provided, choose to reference variables within an object instead of the button’s current variables.
Variables in button Template String Returned String
username: “chrizzz”
months: 12
Thanks /$username$/ for the /$months$/ months! Thanks chrizzz for the 12 months!


Edit

URL Encode String #

Encodes a string by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. Useful for using HTTP Request command as browsers do this part automatically for you.

Box Name Type Description
Save Variable As String Variable name to save the encoded string.
String (text) String String to encode.

Edit

String Split to Array #

Splits a string value into an array. If an array does not already exist, a new array will be created.

Box Name Type Description
String (text) String The string you want to be split into an array.
Separator Symbol Separating symbol for the array. Defaults to ‘,’.
Array Name String Name of the array to save the split values to.