lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> The problem du jour is to efficiently find single-word matches, that
> is if we match 'dog' we don't match 'dogged'.

How about this:

function single_word_match(s,w)
	local m=s:match("%w*"..w..""%w*")
	return m==w
end

That is, find the largest word that has your word and ensure it is exactly
that word.