Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 4 years ago

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

0
I just search answer for the same question. Found method for whitespaces string:gsub("(.*)%s.*$","%1") ErtyPL 129 — 2y

1 answer

Log in to vote
1
Answered by
ErtyPL 129
2 years ago

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.

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 PROREMIXPL 60 — 2y
Ad

Answer this question