-
Notifications
You must be signed in to change notification settings - Fork 0
New String Functions
Irtsa edited this page Feb 8, 2025
·
3 revisions
These functions extend from the current String object/class from greyscript.
The following are a list of new functions that can be utilized.
Will capitalize the first letter of said string.
print("hello!".capitalize)
-- "Hello!"Will fill space on the left side of the said string using filler until the length of the string is equal to amount.
print("hello".lfill(20))
-- "000000000000000hello"
print("hello".lfill(10, " "))
-- " hello"Will fill space on the right side of the said string using filler until the length of the string is equal to amount.
print("hello".rfill(20))
-- "hello000000000000000"
print("hello".rfill(10, " "))
-- "hello "Will replace instances of "{}" in said string with items given in Variables in the order of the given Variables.
print("Hello {}! Today is {}.".format(["User","Friday"]))
-- "Hello User! Today is Friday."Will split the string into a list comprising of substrings of sizes equal to groupsize.
print("Hello! How are you?".group(3))
-- ["Hel", "lo!", " Ho", "w a", "re ", "you", "?"]Will return the string as a list.
print("hello!".list)
-- ["h", "e", "l", "l", "o", "!"]