[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Case-insensitive gsub?
- From: Peter Wang <tjaden@...>
- Date: Fri, 20 Apr 2001 11:12:00 +1000
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?