Follow up on "Match line IF other line is NOT there"

Posted by Blixel on Tue 01 Dec 2020 06:24 PM — 3 posts, 17,655 views.

#0
This is the thread I want to reply to, but it's too old at this point, so I can't reply direclty.

https://www.gammon.com.au/forum/?id=14057&reply=3#reply3

I want to make a plugin like the one Nick made for me so that it will match multiple conditions. I thought I could put a pipe symbol in the match line, but that doesn't seem to work.

Here is what I'm trying to match

Instead of: match="M - *"

I want: match="M - wererat|M - wererat, wererat|M - wererat, wererat, wererat"

It works if I just have match="M - wererat", but if I try to match 2 or 3 wererats, it doesn't work.

Does anyone know how I can modify this match line to match all three conditions?

Thank you.
USA Global Moderator #1
First, why? "M - *" will also match all of those.

To answer, pipe will only work if you're using regular expression matching, which is not true by default. You have to add regexp="y" to the trigger xml tag and then put parentheses around all of the different options (read the section on Subpatterns in https://www.mushclient.com/scripts/doc.php?general=regexp to understand why).
Amended on Tue 01 Dec 2020 07:37 PM by Fiendish
#2
Fiendish said:

First, why? "M - *" will also match all of those.


Hopefully this will make sense. I'm aware that "M - *" will match all. However, I need to know when a monster is a "wererat" (or "werewolf" or "werebear"). "M - *" tells me there is a monster in the room, but it doesn't tell me what kind it is. In my game, if you get attacked by a were-creature, you become infected and can turn into a were-creature yourself. There's a cure, but it's a lot easier to just avoid it in the first place.


Fiendish said:
To answer, pipe will only work if you're using regular expression matching, which is not true by default. You have to add regexp="y" to the trigger xml tag and then put parentheses around all of the different options (read the section on Subpatterns in https://www.mushclient.com/scripts/doc.php?general=regexp to understand why).


Ah, ok. So add regexp="y". Thanks a lot. I will read the link.