lua-users home
lua-l archive

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


Samuel Chi wrote:
just like '*(?P<name>...)*' in python.
for example, i want to extract 1,10,'int', 'id' from '1-10:int=id'.
how to do?

Due to multiple return feature of Lua functions,
it can be done yet simpler than in Python, for example:

n1,n2,w1,w2 = string.match ('1-10:int=id', '(%d+)%p(%d+)%p(%w+)%p(%w+)')

(Of course, you can use more meaningful names than n1,w1,...)

--
Shmuel