lua-users home
lua-l archive

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


I've been processing Midi files and streams with Lua, treating them as strings and searching for something like:

"^([\144-\159][%z\001-\127][\001-\127])(.*)" -- (a note-on event is 0x9-, note number, velocity for example)

I was having a bit of trouble with it until I realised that (from the manual):

%z: represents the character with representation 0.

...means "\0", not "0". Likewise:

A pattern cannot contain embedded zeros. Use %z instead.

I admit I hadn't thought about these two lines much apart from wondering what was special about the character "0" that required one to escape it. Perhaps for the likes of me the first line could be changed to:

%z: represents the character with representation 0 ("\0")

Also this kind of processing would be easier if hexadecimal escape codes were allowed.

Other than that, the only problem I have with Lua is how unattractive it has made the prospect of going back to program in C!