Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Vulcaned
Newbie


Joined: 02 Jun 2008
Posts: 2

PostPosted: Mon Jun 02, 2008 8:20 pm   

Quick help with a task...
 
Hey! So I need to trim a single phrase out of a line of text, but can't seem to do it...

The text is formatted like this:

Code:
Level 89  : Text           135    83%     451
Level 100 : Text            89    15%     139


I've tried a trigger for {Level %1 : %2 %d*}
And then %trim(%2) to get the text (a spell name)
But it doesn't seem to work. When I try to #show %trim(%2) it just gives me:
Text 135 83%

Any suggestions?

-V
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jun 02, 2008 9:06 pm   
 
I added the code tag to your post to preserve the spacing.

#trig {Level (%d)%s: ([%w ])%s(%d)%s(%d)~%%s(%d)} {#show %1 - %2 - %3 - %4 - %5}

Will match properly. See also this help file. This example assumes certain things about the text (namely, that it only contains alpha characters and spaces). You can add any other characters you need to match to the [%w ] range.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jun 02, 2008 10:48 pm   
 
To better help you understand why you had a problem, here are two technical explanations about the trigger parser:

1)%1...%99 equate to the * wildcard.

2)the parser always goes with the broadest match it can find.

Given those two things, your pattern (Level %1 : %2 %d*) can be rewritten as this pattern (Level * : * %d*) and the helpfile Fang connected you to should be able to explain why your %2 ended up being "Text 135 83%" instead of just "Text" as you expected.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vulcaned
Newbie


Joined: 02 Jun 2008
Posts: 2

PostPosted: Tue Jun 03, 2008 8:34 pm   
 
Wow! Thanks for the quick reply and the very detailed explanation :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net