Q:

LUA string, remove all characters after last occurrence of white space

Anyone knows or have idea how to remove all characters after last occurrence of white space in LUA, for example 
foo = "This is some string"
to get 
bar = "This is some"

A:

Try
bar = foo:gsub("(.*)%s.*$","%1")

The pattern greedily captures everything until a whitespace is seen and discards the rest of the string. The key point here is greedily, which has the effect of finding the last whitespace.

