help with *

Posted by Cargo on Tue 08 Apr 2008 07:18 AM — 6 posts, 28,455 views.

Canada #0
hey i have a question.
i have a trigger from when a group mate comes back when they tell the group back i tell the group "welcome back <name>"
is there a way i can make it so * signifies only one word and not just anything before * tells the group, 'back'.
example of what it is:

joe schmoe from idaho tells the group, 'back'
you tell the group, 'welcome back joe schmoe from idaho!'

example of what i want:
joe schmoe from idaho tells the group, 'back'
you tell the group, 'welcome back idaho!'

any ideas would be appreciated
Canada #1
ps: this is just a general example, first thing that popped into my head.
#2
<triggers>
<trigger
enabled="y"
match="^(\w*) tells the group, 'back'$"
regexp="y"
sequence="100"
>
<send>gt welcome back %1</send>
</trigger>
</triggers>
Amended on Tue 08 Apr 2008 08:54 PM by SKYY
Australia Forum Administrator #3
Quote:

joe schmoe from idaho tells the group, 'back'
you tell the group, 'welcome back idaho!'


Do you really mean: 'welcome back joe!' ?

That would make a bit more sense.

In that case I would agree with Skyy but with an amendment:


<triggers>
  <trigger
   enabled="y"
   match="^(\w+) (.* )?tells the group, 'back'$"
   regexp="y"
   sequence="100"
  >
  <send>gt welcome back %1</send>
  </trigger>
</triggers>


This is now a regular expression. See http://www.mushclient.com/regexp for more details about regular expressios.

Anyway, first it looks for a word (\w+) which would be the person's name (eg. Joe), followed by a space, and then other stuff (.* )? which is optional, and then "tells the group, 'back'".

See http://www.mushclient.com/pasting for how to copy that into the client.
Amended on Tue 08 Apr 2008 09:09 PM by Nick Gammon
USA #4
http://www.gammon.com.au/mushclient/regexp.htm

That link will explain regular expressions. What Skyy posted will work perfectly fine, but I would use ="^(\w+) tells the group, 'back'$" so that it will not match " tells the group, 'back'$"

Also, when creating regular expressions, you can test them with this website: http://www.nvcc.edu/home/drodgers/CEU/Resources/test_regexp.asp
USA #5
Bah, curse Nick for being up at a ridiculous hour and posting helpful information while I'm working and posting.

Makes my posts seem redundant :p