I would like to trim a string in Lua but I'm struggling I think because of the special characters in the string.
E.g. str = "RG Ph 0%/15.00bpm"
I would like to remove everything after and including the "/"
so thatstr = "RG Ph 0%"
I have found the following code but I don't think it handles the "%"
and "/"
properly:
local string_gsub = string.gsub
function string.trimRight( str, char )
char = char or "%s"
return ( string_gsub( str, "(" .. char .. "*)$", "" ) )
end
Any ideas?