lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> >Is there any way for `gsub' to match strings without regard to case?
> 
> Not directly. But you may make do:
> 
>    Change the literal parts of the pattern to be case insensitive:

Thanks.  I came up with:

function gisub(s, pat, repl, n)
    pat = gsub(pat, '(%a)', 
               function (v) return '['..strupper(v)..strlower(v)..']' end)
    if n then
        return gsub(s, pat, repl, n)
    else
        return gsub(s, pat, repl)
    end
end

This might have been asked before, but why didn't you guys make
`gsub' also accept `nil' for the final parameter?