[TxMt] Matching nested pairs
Gavin Kistner
gavin at refinery.com
Sat Oct 8 04:54:50 UTC 2005
I decided to just make my own Lua module, by hacking an existing
module and (for now) making up my own UUID. I'm 95% done, but for two
(related) issues:
In Lua, you can have a multi-line string delimited by [[ ... ]]. For
example:
local theMessage = [[
Hello world
How are you doing?
]]
I've got that one covered. However, Lua is tricky and allows you to
have nested [[..]] pairs within this block. So, for example:
local theExample = [[
Hello world
In Lua, a string can contain nested [[...]] pairs.
This includes a case like [[ hi [[ there ]] ]]
More string]]
Is it possible to do this? I don't think so in general PCRE, but
didn't know if TextMate or Oniguruma had some sweet balancing.
Right now I have:
{ name = 'string.quoted.multiline.lua';
begin = '(?<!--)\[\[';
end = '\]\]';
swallow = '\[\[(.|\r)*?\]\]|\\.';
},
which handles a single pair of [[..]] on the same line inside a
block, but doesn't handle multiple nesting or (for reasons I don't
understand) handle a single pair across multiple lines. Where can I
find more information on the 'swallow' bit?
More information about the textmate
mailing list