lua-users home
lua-l archive

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


On Wed, Jun 8, 2011 at 12:46 AM, Igor Medeiros <igorosbergster@gmail.com> wrote:
> (systemScreen([1 .. 9])|systemAudio([1 .. 9]))

OK, your problem is that Lua patterns do not do alternatives like
this. So you will have to split the match into two patterns:

ok = s:match 'systemScreen%(%d%)' or s:match 'systemAudio%(%d%)'

Here %d stands for [0-9], and we've had to escape '(' which otherwise
would mean a capture.

'ok' gives the actual matched string, so if s was 'a =
systemScreen(1)' then ok would be 'systemScreen(1)' .The 'or'
operation returns the value, so that s = 'print(systemAudio(9))' will
result in ok = 'systemAudio(9)'.

steve d.