aliases and wildcards

Posted by Tspivey on Thu 06 Apr 2006 10:57 PM — 4 posts, 19,231 views.

Canada #0
Hello. When I used Tintin, I could do something like:
#alias {h} {cast heal}
and the following would result:
h: cast heal
h argon: cast heal argon
I tried doing the same thing in Mush, but couldn't figure out how to do it without writing two aliases for each one I wanted to create this way. Is there something I'm missing? Since writing
match on: h
send: cast 'cure light'
only works if I type h, without any extra args, and "h *" in match only works if I type h with an arg or a space after it.
Australia Forum Administrator #1
A simple regular expression will do that:


<aliases>
  <alias
   match="^h( .*){0,1}$"
   enabled="y"
   regexp="y"
   sequence="100"
  >
  <send>cast 'cure light'%1</send>
  </alias>
</aliases>


That would match on "h" on its own or "h" followed by a space and then anything. The "anything" might be too broad, so this might be better:


<aliases>
  <alias
   match="^h( [A-Za-z]{1,}){0,1}$"
   enabled="y"
   regexp="y"
   sequence="100"
  >
  <send>cast 'cure light'%1</send>
  </alias>
</aliases>



This would only match on "h <something alphabetic>" assuming your names are like A-Z and a-z, however if other things like underscore can be in names you just put that inside the square brackets.

The notation {0,1} means "zero or 1 of these things", and {1,} means "one or more".
Australia Forum Administrator #2
See my post about using regular expressions:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5089
Australia Forum Administrator #3
See this new post:

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

I have made an alias that will create aliases "like tintin" for you.