How To Exclude everything but the variable?

Posted by Karl_Newbie on Sun 25 Jul 2004 04:30 PM — 4 posts, 16,227 views.

USA #0
Okay, from a status command and I get several pages of infomration.
type army status
return below

Pikemen [ID234c05] training: 3 dailycost: 117 morale: 234 [mobilized]
Pikemen [ID23408] training: 3 dailycost: 117 morale: 234 [mobilized]
Knights [274353] training: 14 dailycost: 72 morale: 104 [reserve]
ballista [26143] training: 3 dailycost: 186 morale: 252 [mobilized]
Peasants [479657] training: 1 dailycost: 17 morale: 4732 [reserve]
Slingers [489549] training: 3 dailycost: 27 morale: 1350 [mobilized]
wagons [4934602] training: 2 dailycost: 3 morale: 231 [engaged]
Peasants [4973952] training: 3 dailycost: 108 morale: 216 [panicked]
ballista [5267756] training: 3 dailycost: 186 morale: 252 [reserve]
Pikemen [2734708] training: 3 dailycost: 117 morale: 234 [mobilized]
ballista [5267757] training: 3 dailycost: 186 morale: 252 [mobilized]
Knights [5462522] training: 13 dailycost: 12 morale: 72 [reserve]
Peasants [5611447] training: 3 dailycost: 1 morale: 216 [mobilized]
RoyalGuard [7169887] training: 15 dailycost: 13 morale: 2814 [mobilized]
Slingers [7545073] training: 3 dailycost: 2 morale: 1340 [mobilized]

-----------------------------------------------------------
without the ----
Now I just want to be able to type 'army status *' ie 'army status pikemen' or whatever and just see those lines, which means excluding every other line that doesn't begin with that wildcard. Okay, here is my simple set the variable alias, works fine.

<aliases>
<alias
match="as *"
enabled="y"
expand_variables="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>SetVariable &quot;astat&quot;, &quot;%1&quot;
send &quot;army status&quot;</send>
</alias>
</aliases>

Okay, I set a variable named 'astat' and send the command to the mud.


But when I try to make a simple trigger idea I have no idea how to do so successfully.
I tried different sorts, made sure to expand the variable, had regular expression checked when I need it, etc.
Sort of like


(?!@astat) [(.*)] training: (.*) dailycost: (.*) morale: (.*) [(.*)]

Now I got the variable to match successfully once and be excluded, but I can't figure out how to omit anything BUT the variable.

So fustrating blah. :)

Amended on Sun 25 Jul 2004 04:50 PM by Karl_Newbie
Australia Forum Administrator #1
You were on the right track. This seems to work for me:


<triggers>
 <trigger
 custom_colour="2"
 enabled="y"
 expand_variables="y"
 match=
"(?!@astat)(.*?) \[(.*?)\] training: (.*?) dailycost: (.*?) morale: (.*?) \[(.*?)\]"
 omit_from_output="y"
 regexp="y"
 sequence="100"
 >
 </trigger>
</triggers>


The change was that the negative look-ahead assertion you had does not consume characters, so I had to add (.*?) after it.

Also, putting \ in front of the brackets, otherwise they have a different meaning.

Amended on Sun 25 Jul 2004 10:19 PM by Nick Gammon
USA #2
Works perfectly.
I had read a previous forum thread on the purpose of (.*? ) vs (.*) and didn't think it would have helped me :D
thanks.
Amended on Tue 27 Jul 2004 09:24 PM by Karl_Newbie
USA #3
Nah, it doesnt really. Well, except for specific cases, the big thing he changed was the escaping of the brackets.