I'm trying to write a multiline regex to match our MUD's roomname, description and exits in one shot. I've tested the regex on regex101.com and you can see that in action here (https://regex101.com/r/o0AzVu/1/).
The regex works but the problem is that it matches too much. The essence of the issue is that I need the description to form a unique hash (I don't have the room's vnums, and room names and exits are not unique), and the room desc is not a fixed number of lines, it's like this (e.g.):
Room Name (inside)
desc 1
desc 2
...
desc n
[Exits: north south]
So the trigger I've written is like this:
<trigger
enabled="y"
lines_to_match="30"
keep_evaluating="y"
match="\A(.*) \((inside|city|field|forest|hills|mountain|swim|noswim|air|desert|underground|swamp|moor|space|underwater|small-fire|fire|big-fire|cold|acid|lightning|holy|evil|jungle|path|road|plain)\)([\s\S]+)\[Exits\: ([^\]]+)\]\Z"
multi_line="y"
regexp="y"
script="got_room_name"
sequence="100"
>
</trigger>
Whose regex works on regex101.com but NOT AT ALL on MUSH. If I replace \Z with say .* then it starts to work but it matches too many lines - it will match the previous 30 lines in the buffer which will include the previous room I was in before moving to the current one, so it all gets very confused very quickly.
How can I limit the regex to just new lines received since the last match or perhaps I should write the regex so it searches backwards? Perhaps there is a special character I can match which will anchor it to the end of the input from the MUD, like an EOF or something?
Perhaps I'm going about this the wrong way?
In mudlet I remember doing this by matching the room name - that would trigger a gate/filter thing which would suck up all the new lines received until the Exits line appeared whereby the gate/filter thing would close. Perhaps there is some similar mechanism in MUSH or maybe I could simulate that?
Thank you for your help,
Woody.
The regex works but the problem is that it matches too much. The essence of the issue is that I need the description to form a unique hash (I don't have the room's vnums, and room names and exits are not unique), and the room desc is not a fixed number of lines, it's like this (e.g.):
Room Name (inside)
desc 1
desc 2
...
desc n
[Exits: north south]
So the trigger I've written is like this:
<trigger
enabled="y"
lines_to_match="30"
keep_evaluating="y"
match="\A(.*) \((inside|city|field|forest|hills|mountain|swim|noswim|air|desert|underground|swamp|moor|space|underwater|small-fire|fire|big-fire|cold|acid|lightning|holy|evil|jungle|path|road|plain)\)([\s\S]+)\[Exits\: ([^\]]+)\]\Z"
multi_line="y"
regexp="y"
script="got_room_name"
sequence="100"
>
</trigger>
Whose regex works on regex101.com but NOT AT ALL on MUSH. If I replace \Z with say .* then it starts to work but it matches too many lines - it will match the previous 30 lines in the buffer which will include the previous room I was in before moving to the current one, so it all gets very confused very quickly.
How can I limit the regex to just new lines received since the last match or perhaps I should write the regex so it searches backwards? Perhaps there is a special character I can match which will anchor it to the end of the input from the MUD, like an EOF or something?
Perhaps I'm going about this the wrong way?
In mudlet I remember doing this by matching the room name - that would trigger a gate/filter thing which would suck up all the new lines received until the Exits line appeared whereby the gate/filter thing would close. Perhaps there is some similar mechanism in MUSH or maybe I could simulate that?
Thank you for your help,
Woody.