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

Gammon 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
Register forum user name
Forgotten password?

Regular expression matching on everything

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

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

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)

Amended on Tue 14 Jul 2009 08:47 PM (UTC) by Phaeton

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  (525 posts)  [Biography] bio
Date Reply #2 on Tue 14 Jul 2009 08:52 PM (UTC)
And one that's probably better since it's examples are all mudding based...


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.


It is now over 60 days since the last post. This thread is closed.     [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.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]