[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]  General
. . -> [Subject]  Regular Expression Trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Regular Expression Trigger

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


Posted by Xavious   (41 posts)  [Biography] bio
Date Mon 27 Apr 2009 08:36 AM (UTC)

Amended on Mon 27 Apr 2009 08:37 AM (UTC) by Xavious

Message
What I'm trying to accomplish isn't very difficult. The only limitation is my knowledge of how to utilize regular expressions. Example trigger text:
SpiderDrider the avatar of Lloth flies north.

I have two wild cards that I certainly need.. so here is my generic version:

* flies *.

%1 for the character name and %2 for the direction of travel

My problem is that after the character name they could have any number of other words identifying the title, but I only need the first word to be saved. In the example above it would be "SpiderDrider", however the extra text accompanying is "the avatar of Lloth." I need a way to weed out the additional words no matter how many there may be.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #1 on Mon 27 Apr 2009 05:17 PM (UTC)
Message
^(\w+) .*flies (.+)\.$


Explanation of the above regular expression:

^   - Line begins here.
\w  - any alphanumeric character.
\w+ - one or more of any alphanumeric character.
.   - any character.
.*  - zero or more of any character.
.+  - one or more of any character.
\.  - A simple, literal .
$   - Line ends here.


The () specify captures, or in other words, allow the values matched within them to be assigned to %1, %2 and so forth.
[Go to top] top

Posted by Xavious   (41 posts)  [Biography] bio
Date Reply #2 on Wed 29 Apr 2009 09:00 AM (UTC)
Message
I appreciate the help. I'm going to have to get the hang of regular expressions, so I can accomplish more complex data capture. I haven't got this trigger to work yet, but I've also redefined my strategy on this game :)
[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.


3,500 views.

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.

[Home]


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]