example: save/3685801660/test
I’m trying to get /test after the numbers through string
you could use string.find to find test
1 Like
If the length of the string minus the word at the end is always the same, you can use string.sub. If not, you’ll need to use string patterns. The following code should do what you want:
local function getWordAtEnd(str)
return str:match("/([%w%s]-)$");
end
The pattern above basically means match any letter/number (%w) or space (%s) that happens after a / but is also at the end of the string (the $ at the end). The parentheses are a capture group so it’ll return only those things. You can find more info on how this works here.
3 Likes
Being a bit nitpicky, but you could also use [^/]+$
for the pattern in case of there being other symbols after the /
or just wanting a shorter or simpler pattern for whatever reason.
3 Likes