Register forum user name Search FAQ

Gammon Forum

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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Having an optional target in an alias

Having an optional target in an alias

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


Posted by Tony Chamberlain   (2 posts)  Bio
Date Wed 10 Aug 2016 07:45 PM (UTC)

Amended on Wed 10 Aug 2016 09:31 PM (UTC) by Tony Chamberlain

Message
I tried searching various helpfiles and searched this forum for any subject with alias but couldn't find exactly the answer I needed.

I programming an aliaas on aardwolf mushclient. I have tried to combine the following two aliases:
Note: I created a MushClient variable called Heal
Heal set to Cure Light
Both aliases have Enabled, Regular Expression and Expand Variables checked.

Alias 1:
^zz$
cast '@Heal'

Aliast 2:
^zz (.*)$
cast '@Heal' %1

This works great if type zz
I get cast 'cure light' (which is on me)
or typeing zz joe
I get cast 'cure light' joe

However if i remove Alias 1, whenever i just type zz
the mud returns : Unknown command please check help files.

It seems to require there be soemthing there to capture. I tried various combinations of ?, ?: and using a (.*|) to try to get it to work if nothing was there. Is this possible in regexp to have it match if nothing is there and have %1 just be ""
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 10 Aug 2016 08:33 PM (UTC)
Message
Template:faq=50 Please read the MUSHclient FAQ - point 50.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Tony Chamberlain   (2 posts)  Bio
Date Reply #2 on Wed 10 Aug 2016 09:40 PM (UTC)

Amended on Wed 10 Aug 2016 09:41 PM (UTC) by Tony Chamberlain

Message
Thanks. Actually what I tried is almost exactly what that FAQ says. IF anyone else has this problem I finally noticed what i was doing wrong:

Whenever I tried:
^zz (.*)?$ it would fail because I had a space between zz and target, which regexp would look for and fail to find.

You have to have to have:
^zz(.*)?$ with no spaces at all.

Thanks again for the help.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 10 Aug 2016 10:48 PM (UTC)
Message
Yes, or put the space in the optional part, as the FAQ says:


^zz( .*)?$


Now that matches on zz (but not zzfoo) because you have the space there.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


12,710 views.

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

Go to topic:           Search the forum


[Go to top] top

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