[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Regular expression matching on everything
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Regular expression matching on everything

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Oriol   (31 posts)  [Biography] bio
Date Tue 14 Jul 2009 04:59 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Phaeton   Canada  (8 posts)  [Biography] bio
Date Reply #1 on Tue 14 Jul 2009 07:54 PM (UTC)  quote  ]

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.
[Go to top] top

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Reply #2 on Tue 14 Jul 2009 08:52 PM (UTC)  quote  ]
Message
And one that's probably better since it's examples are all mudding based...

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5089

Written by Nick!
[Go to top] 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.


2,569 views.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]