lua-users home
lua-l archive

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


i need to parse lines like '# aaa', '# aaa.bbb' and '# aaa.bbb.ccc' and tried

 a,_,b,_,c = string.match( line, '^# (%d+)(%.(%d+)(%.(%d+))?)?' )

the '# ' at line start isn't important
first attempt '^# (%d)' succeeds
second '^# (%d+)(%.(%d+))?' failed, %. replaced by simple . too; 

is optional group (...)? not supported ?
i tried (...){0,1},  too. (what else could i do ?)

using perl $s =~ /^# (\d+)(\.(\d+)(\.(\d+))?)?/ reading matches in $1,$3,$5 works as expected.
the job has been done, but i'm wondering wether lua could do this too

thanks for answers
andreas

please excuse my english