lua-users home
lua-l archive

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


> > _,x = _,nil or f()
> > print(x)              -- x = 1 !!!
> 1
> 
> Shouldn't be 99?

Read as:

	_,x = _,(nil or f())

"nil or 1" gives 1.

http://lua-users.org/wiki/AssignmentTutorial

from

http://lua-users.org/wiki/TutorialDirectory

> - -- Second question:
> 
> > s = 'just a test'
> > print(string.gfind(s, "([%w%p]+)%s+([%w%p]+)$")())    -- ok
> a   test
> > print(string.gfind(s, "([%w%p]+)%s+([%w%p]+)")())     -- ok
> just    a
> > print(string.gfind(s, "^([%w%p]+)%s+([%w%p]+)")())    -- returns nil
!!!
> 
> > s = '^just a test'
> > print(string.gfind(s, "^([%w%p]+)%s+([%w%p]+)")())    -- now it
works
> !!!
> just    a
> 
> Why the caret is being taken *literally*? Shouldn't it be a special
char
> indicating a regex start anchor?

I believe there is a bug here which has been pointed out before.

--nick