-- the word taken.
local function take_word(str)
-- A word must always start with a-z (in particular, λ is not a valid
- -- start of a word).
- res, newstr = utf.match(str, "^([a-zA-Z][%a%d%+%-%,_]+)(.*)")
+ -- start of a word). A word must always end with a letter or a digit
+ res, newstr = utf.match(str, "^([a-zA-Z][%a%d%+%-%,_]*[%a%d]+)(.*)")
+ if not res then
+ -- The above does not catch single letter words
+ res, newstr = utf.match(str, "^([a-zA-Z])(.*)")
+ end
return res, newstr or str
end