lua-users home
lua-l archive

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


On Sat, May 30, 2015 at 9:05 AM, Александр Машин <alex.mashin@gmail.com> wrote:
> Dear all,
>
> It seems that a string capture within a function capture breaks the latter.
>
> Example:
>
> local  re=  require  "re"
>  local  str=  'abaababbb'
> local  captured
> local  function  func(s)  captured=  send
> local  g        =  re.compile("( 'b' / ( 'a' -> 'A' ) )* -> func",  {func=
> func})
> g:match(str)
>
> print captured --> prints "A" but "AbAAbAbbb" expected
>
> Is this a bug or a feature?

A feature.

Change:
local  function  func(s)  captured=  send

To:
local  function  func(...)  print ( ... )  end

And see what happens.

-Parke