Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to remove everything after a certain character in a string?

say i have a string like "100 / 100" how would I remove everything after the "/"?

1 comment

0

I just search answer for the same question. Found method for whitespaces string:gsub("(.)%s.$","%1")

1 answer

Hey Ho! It seems the easiest way is this one.


local variableName = ("some.string"):gsub("(.*)%..*$","%1")
print(variableName)--[[just to check is it working]]

%. stands for the dot operator (...) according to https://www.lua.org/pil/20.2.html

Please accept an answer. Don't fear to ask me directly.

1 comment

0

s = "Deadline is 30/05/1999, firm" date = "%d%d/%d%d/%d%d%d%d" print(string.sub(s, string.find(s, date))) --> 30/05/1999

This discussion is preserved as it was. New answers, comments, and votes are closed.