Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Programming ➜ General ➜ Regular expression wildcard

Regular expression wildcard

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by ErockMahan   (81 posts)  Bio
Date Sat 26 Jan 2013 01:08 AM (UTC)

Amended on Mon 28 Jan 2013 05:13 PM (UTC) by ErockMahan

Message
I have a corpse collection set of triggers that activates on this:

You get Corpse of a Rat.

But every so often, when too many lines come through at once , my prompt ends up on the same line and I get this:

< 15973hp 238mana 102mv > You get Corpse of a Rat.

Now, without using regular expressions, I can do this:

*ou get * of *.

That way, whether the line starts with "Y" or "< 15973hp 238mana 102mv > Y" it will work just fine.

The problem, though, is that I have to do this as a regular expression (because it may not always be Corpse, but also Sludge, Remains, etc., but not "sword" or "helm" etc.)

With a regular expression, though, it doesn't seem to pick it up at all:

^(.*?)ou get (@!corpsetype) of (.*?)\.$

Now I know that the (@!corpsetype) works, because the trigger is perfectly fine whenever the line doesn't have the prompt show (You get Corpse of a Rat).

But whenever the line starts with < 15973hp etc, the trigger fails, and I would THINK that the (.*?) wildcard would account for that, but it doesn't seem to. I have tried it with and without the "ou" but nothing changes.

Is it possible to have a regular expression accomplish what I'm trying to do?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 26 Jan 2013 02:12 AM (UTC)
Message
The conversion to regular expressions (done by the button in the trigger) is what it does anyway when a non-regular expression is processed. Please post the whole thing.

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by ErockMahan   (81 posts)  Bio
Date Reply #2 on Mon 28 Jan 2013 05:15 PM (UTC)
Message
<triggers>
<trigger
expand_variables="y"
group="getcorpse"
match="^(.*?) get (@!corpsetype) of (@!elemental)\.$"
name="elementalcorpse"
regexp="y"
send_to="12"
sequence="300"
>
<send>world.note "elemental"
</send>
</trigger>
</triggers>
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 28 Jan 2013 08:45 PM (UTC)
Message
The trigger was not enabled.

world.note doesn't work. It must be Note (not note).

At least post a trigger that works, thanks.

Using a modified trigger:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="getcorpse"
   match="^(.*?) get (@!corpsetype) of (@!elemental)\.$"
   name="elementalcorpse"
   regexp="y"
   send_to="12"
   sequence="300"
  >
  <send>Note "elemental"
</send>
  </trigger>
</triggers>


It worked in both cases:


You get Corpse of a Rat.
elemental
< 15973hp 238mana 102mv > You get Corpse of a Rat.
elemental


I suspect another trigger is kicking in on the prompt, preventing this one from firing. Make sure your "prompt" trigger is set as "keep evaluating".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,408 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.