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
Salaric
Beginner


Joined: 10 Jun 2008
Posts: 17

PostPosted: Mon Sep 29, 2008 3:52 am   

Database question
 
Okay, I'm sure this is simple enough but I'm struggling with it. I'm trying to figure out how to get more than two words to show up in a database or stringlist. For example

Salaric (Mail Room)

I want it to capture Salaric and then both 'Mail' and 'Room'. I can make the trigger itself just fine

(%w) * ~((%w) (%w)~)

It's just getting the information into databases that I'm struggling with. I can just get 'Salaric - Mail' to work. Help?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Sep 29, 2008 6:42 pm   
 
This pattern will do the trick

(%w) * ~((%w %w)~)

Each set of parentheses says group these words together in a match. So you were essentially grouping each matched word separately.

Review the Pattern Matching documentation for more info.
_________________
Asati di tempari!
Reply with quote
Ralph1971
Wanderer


Joined: 01 Mar 2008
Posts: 64

PostPosted: Sat Oct 04, 2008 7:25 pm   
 
what if it's more than 2 words sometimes, 1 word sometimes, etc? (a ring, a golden helm, a diamond studded plate).. (*) seems to just get the first word into the variable.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Oct 04, 2008 7:52 pm   
 
EDIT: Thinking about it, your issue is more likely to be related to how zMUD handles arguments. You need to do #var Whatever {%1} rather than #var Whatever %1 when %1 can contain more than one word. Try the below if that's not the issue - * should be fine, really.

You'll need something a little more complex in that case. A regex like:

(\w+) [^\(]+\(((?:\w+ )+)\)

should do the trick. I coloured the brackets () to hopefully make it clearer which goes with which.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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