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.
Entire forum
➜ MUSHclient
➜ Lua
➜ Regular expression matching on everything
Regular expression matching on everything
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Oriol
(31 posts) Bio
|
Date
| Tue 14 Jul 2009 04:59 PM (UTC) |
Message
| Hey,
Sorry to bother you guys again, but I'm having more trigger problems...
I'm trying to make a line that will match on when someone in the group except me is in a fight and I want it to get the name of the person that's fighting.
So I thought I'd make a regular expression that would match on the mob's name that's hitting, the damage type and the person who's been hit. So I made this regexp, but it seems to be matching on every line for some reason and not returning my wildcards.
<trigger
match="^.*!Your scratches|hits|wounds|injures|mauls|decimates|devastates|maims|MUTILATES|DISMEMBERS|DISEMBOWELS|MASSACRES|\*\*\* MASSACRES \*\*\*|\*\*\* DEVASTATES \*\*\*|\*\*\* OBLITERATES \*\*\*|\*\*\* DEMOLISHES \*\*\*|\*\*\* ANNIHILATES \*\*\*|\*\*\* DESTROYS \*\*\* (w+!you!him!her!it!them)[!.]$"
regexp="y"
script="gfight"
sequence="100"
enabled="n"
>
</trigger>
For example, it should match on the wolf's bite hits Kevin, but not your slash hits Kevin.
Note that it's disabled because t was matching on every line and giving me compile errors.
Thanks all. | Top |
|
Posted by
| Phaeton
Canada (8 posts) Bio
|
Date
| Reply #1 on Tue 14 Jul 2009 07:54 PM (UTC) Amended on Tue 14 Jul 2009 08:47 PM (UTC) by Phaeton
|
Message
| You can't just assert negatives with !NotThis. Here's an example you can probably build from, simplified somewhat. You probably want to use a negative look behind like so.
^.+(?<!You) (scratches|hits|wounds) (\w+)[.!]$
Personally, I deal with this situation with grammar (may not be possible on the MUD you play on), and by matching based off colours. However, you can build in your other assertions as needed with that match. This would capture hit hit and Kevin's name.
Edit: It's worth noting that you'll want to do some things programatically rather than trying to build the kitchen sink into the match. It opens up more options for actions to take based on dynamic names and that kind of jazz.
Also, I highly recommend you check out a regex tutorial. There's one here, but I find the tutorial at http://www.regular-expressions.info/ to be pretty delightful. | Top |
|
Posted by
| WillFa
USA (525 posts) Bio
|
Date
| Reply #2 on Tue 14 Jul 2009 08:52 PM (UTC) |
Message
| |
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.
15,418 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top