Sorry, it took a while. The matter was a bit more complicated than I liked it to be (I tried to bruteforce a solution with negative look-aheads, but your output wasn't friendly enough for that), so I had to code something up manually only to forget get myself into an infinite loop and losing all my progress. Whoops. xD
Also, my apologies for misdirecting you. The module you need is 'rex', not 're'. I'm getting my languages and scripting environments confused a little bit!
<triggers>
<trigger
enabled="y"
match="^(.*?([NSWEUD]|[NS][EW])-\w.*)$"
regexp="y"
send_to="12"
sequence="100"
>
<send>local line = "%0"
-- Match upto first letter of description for accuracy.
local exit_re = rex.new("\\\\s([NSWEUD]|[NS][EW])-\\\\w")
local s, e, m = exit_re:match(line, 1)
while (s ~= nil) do
local new_s, new_e, new_m = exit_re:match(line, s+1)
local exit_name = m[1]
local exit_description = line:sub(e, (new_s or 0)-1)
-- You may want to add a trim() to exit_description since your game
-- seems to be littered with spaces in unexpected places. :-)
-- BEGIN -- Do what you want at this point.
Note("Exit found: <" .. exit_name .. ">")
Note("Exit description: <" .. exit_description ..">")
-- END -- Do what you want at this point.
s,e,m = new_s, new_e, new_m
end</send>
</trigger>
</triggers>
There's your trigger. I did some shenanigans with the trigger itself to get the entire line to match for manual processing. I personally always use the Script Function thing because it is far easier to code for; it also offers some extra features that aren't easy to do in this format. Additionally, it gives the bonus of not having a backslash-infestation with regexes like in this particular case. :-)
The way it basically works is to first match a space, followed by a direction, followed by a dash, followed by one letter. The latter is to be as precise as possible with regards to really matching an exit to avoid false positives. Then it looks for the same pattern a second time, but one character after where it found its first match. This should give the second exit. Next, I just fiddle with the indexes and collected information to put the values you want into useful variables. (Note that s or new_s becomes nil if it cannot find a match, so I need to default it to zero, which will give a -1 and be interpreted by Lua as 'until the end of the string'.) Finally, we take the second match we did initially, and use it as a seed for the next loop.
If you can't figure out how to do the (right-)trim of the exit description, let me know and I'll get you a snippet. It should be easy enough to find on the interwebs, though! |