Help with multiline trigger

Posted by Graymane on Fri 21 Mar 2014 06:17 PM — 3 posts, 13,406 views.

USA #0
I'm trying to get a trigger to match on the room name, Exits, and room description in one go.

My MUD outputs the following:


Some Room Name
[Exits: north south up down]
Some optional room desc line.
More optional room desc lines.
[a blank line here]
optional room contents
<Some Prompt>


I'm trying to match the room name (Some Room Name), the exit directions ("north south up down"), and the optional room desc (all non-blank lines after exits terminated by an empty line).

The following sort of works in that it captures the room name, the exits, and only the first line of the description. Adding an extra '\n' before the '\z' to try to match an empty line does NOT work, however.


<triggers>
  <trigger
   enabled="y"
   group="Mapping"
   lines_to_match="3"
   match="^(.+)\n[Exits: (.+)]\n(.*)\n\z"
   multi_line="y"
   name="RoomDetector"
   regexp="y"
   send_to="2"
   sequence="100"
  >
  <send>print (Room Name: %1, Exits: %2, Description: %3)</send>
  </trigger>
</triggers>




Any ideas? I'm just sort of playing around with different modifiers to this basic setup. I do note that if I add (?s) to it, it grabs everything down to the blank line and then the line right after the blank if there one (usually either the prompt or room contents).

[EDIT] Added code tags.
Amended on Tue 25 Mar 2014 08:08 PM by Nick Gammon
USA #1
I did get a 3-trigger version working. I did discover that my mud's newlines tend work as "^\s*$", rather than "^$".
Amended on Fri 21 Mar 2014 08:33 PM by Graymane
Australia Forum Administrator #2
First, here:


[Exits: (.+)]


Since you are matching square brackets you have to escape them, eg.


\[Exits: (.+)\]


Next, since you are saying to match on 3 lines then you won't get lots of lines of description matching.

It's hard to get a multi-line trigger working properly in these situations, your solution of a 3-trigger one is probably the best.