lua-users home
lua-l archive

Re: Reading a conf file

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


Il 2016年9月27日 22:41:44 -0700 Russell Haley <russ.haley@gmail.com> scrisse:
> ...
> 
> local option = line:match("%S+"):lower()
> local value = line:match("%S*%s*(.*)")
>
> if not value then
> ...
Hi,
I think that substituting above with below should work:
 local option, value = line:match('(.-)=(.+)')
 if not option then
 elseif not value then
If you want to ignore spaces, put %s* where relevant, e.g.:
 line:match('%s*(.-)%s*=%s*(.+)%s*')
Ciao.
-- 
Nicola

AltStyle によって変換されたページ (->オリジナル) /