-
Notifications
You must be signed in to change notification settings - Fork 4
String functions
These are the functions that take in sequences of characters (strings) in as input.
Chooses a random character from a string.
[CHOOSECHAR (characters: string)]
Example code:
[CHOOSECHAR "abcdefgh12345"]
> h
[LOOP 10 [CHOOSECHAR "abcdefgh12345"]]
> ['1', 'e', '4', 'd', 'c', 'g', 'g', 'e', 'h', 'f']Puts one or more strings together.
[CONCAT (string1: string) (string2: string...)]
Example code:
[CONCAT "ja" "ja"]
> jaja
[CONCAT "ja" "ja" "ja"]
> jajajaObjectively the best command. Outputs "j" as many times as the number you send next.
[J (amount: int (1-250))]
Example code:
[J 3]
> jjjTells you the length of a specified string.
[LENGTH (base: string)]
Example code:
[LENGTH "jjj"]
> 3Repeats the given string the specified amount of times.
[REPEAT (base: string) (times: integer)]
Example code:
[REPEAT "abc" 2]
> abcabcReplaces a string within a given string with another string.
Replaces all instances at once, not just the first one.
[REPLACE (base: string) (replace: string) (replace with: string)]
[REPLACE "please send help I am locked in Infernos basement" "please send help" "yay"]
> yay I am locked in Infernos basementSends the portion of a string in between the two specified character positions, or cuts an array between the two indexes.
Does not include the end character.
[SLICE (base: string) (start: int) (stop: int) (step: int)]
[SLICE "abcdefghijk" 2 5 2]
> cegNumbers n' Vars || Arrays || Strings || Control flow || Meta || # || How do I start?