lua-users home
lua-l archive

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

On Tue, Dec 29, 2009 at 9:50 AM, Luiz Henrique de Figueiredo
<> wrote:
>> 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.

This won't give the right answer for single_word_match("the dogged
dog", "dog") if I've correctly understood the problem.