lua-users home
lua-l archive

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


Shmuel Zeigerman <shmuz <at> actcom.co.il> writes:
> Let's see another example:
> 
>    print (string.gsub ("abc123", "(.)",
>      function(c)
>        local n = tonumber(c)
>        return n and n+1
>      end))
> 
> > abc234	6
> 
> It seems returning "abc234", 3 would make more sense.
> 

Not at all... six (6) substitutions done.. thats all. thats what the dot do in
Lua's regular expressions. try %d for numbers or %a for letters.

There is a nice info page here... http://www.plop.nl/howto/pattern_matching.php