lua-users home
lua-l archive

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


Salve!

I should escape magic characters (as you always do when using regular expressions). So the corrected version will look like:

----------------------------------------------------------
-- detects .,\"
local find = string.find
function WeirdChars(s)
 if find(s, '[%.,\\"]') then return "weird chars" end
 return nil
end
----------------------------------------------------------
NB! lua uses `%' as escape character.

AMDG,
 Antero Vipunen.

Nilay Tripathi wrote:

function WeiredChars(s)
local x=1
if string.find(s,".")~='nil' then
  x=0
end
if string.find(s,",")~='nil' then
  x=0
end
if string.find(s,"\\")~='nil' then
  x=0
end
if string.find(s,[["]])~='nil' then
  x=0
end
if x==0 then
  return "weired chars"
end
return nil
end