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
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Thu Jun 10, 2004 5:59 am   

Extracting a phrase from a line
 
Well, this could be simple -- but I guess it's not.

I want to extract a spell from a list and add it to my stringlist. Problem is that some "spells" are one-word and others are two-word. See example below:

Spell: detect invisibility - Level 200
Spell: pass door - Level 144
Spell: improved invisibility - Level 241
Spell: armor - Level 90

Right now I only manage to extract the first word (detect, pass, improved, armor). Any ideas how to get both words? Smile

Current trigger
Pattern: ^Spell:%s(*)%s-%sLevel
Value: #additem list_currentspells %1

ps, I thought exchangning the "standard" %w for a * (wildcard) would capture everything, but it doesn't, which strikes me as quite odd, ds.
Reply with quote
nostra
Wanderer


Joined: 23 May 2001
Posts: 68
Location: Sweden

PostPosted: Thu Jun 10, 2004 6:06 am   
 
Well, I got a working solution - but it's not beatiful so if anyone else got something neater feel free to post it [:p]

Pattern: ^Spell:%s(%w) (%w)%s-%sLevel
Value: #additem list_currentspells {%1 %2}
Reply with quote
Serentus
Apprentice


Joined: 28 Sep 2001
Posts: 103
Location: USA

PostPosted: Thu Jun 10, 2004 8:43 am   
 
The (*) was capturing both words. The reason it only added the first word was that it expands to:
#additem list_currentspells detect invisiblity

So it only sees detect. You could still use the (*) int the trigger and the patern would be
#additem list_currentspells {%1}
the {} causes it to be treated as one parameter.
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