[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.gsub (Lua 5.1.1)
- From: George Petsagourakis <petsagouris@...>
- Date: Mon, 6 Nov 2006 16:33:54 +0000 (UTC)
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