Help with strings

I want to get all of the characters before a forward slash in a string. For instance, 50/200 would turn into just 50.


You could probably use string.match like so, using this you can also conveniently get the denominator.

local str = '50/200'
local numerator, denominator = str:match('(%d+)/(%d+)')
print(numerator, denominator) --> 50, 200
1 Like

Or use split. (hbvgghcfbvcbgcnvgbfc)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.