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"
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.