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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Need help with text handling (from wildcard in trigger)

Need help with text handling (from wildcard in trigger)

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


Posted by Lerkista   (57 posts)  [Biography] bio
Date Tue 09 Aug 2016 04:34 AM (UTC)
Message
Hi

I want to make a trigger and do some actions depending the text, for example


Match: You see * in this room


But %1 can be any of this (for example):


a rat
an elephant
Sargent Lewis
Maria


how can i get that %1 be:


cat
elephant
Sargent Lewis


i mean, in the first two cases, eliminate the "a " and "an ", and let "Sargent Lewis" as is

otr other way is with two triggers:

One trigger that match:


"^You see (a|an) (.*?) in this room$


and works with the first 2 cases, but don't know what to do to match the last two

Something like get the name if not start with A and An

Any help??

Thanks
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 09 Aug 2016 04:59 AM (UTC)
Message
How about this?


^You see (?:(?:a|an) )?(.*?) in this room$


The "?:" stops it being captured (so the name is still %1).

What this is looking for is "a" or "an" followed by a space, which itself is optional, preceding the word.

An alternative would be to have the space after each optional word, like this:


^You see (?:a |an )?(.*?) in this room$


And if you omit the "?:" then the matching word (eg. Maria) becomes wildcard #2. eg.


^You see (a |an )?(.*?) in this room$

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Lerkista   (57 posts)  [Biography] bio
Date Reply #2 on Tue 09 Aug 2016 05:16 AM (UTC)
Message
Hi

That works perfect

thanks
[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.


9,904 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 HostDash]