|
Salaric Beginner
Joined: 10 Jun 2008 Posts: 17
|
Posted: 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? |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! |
|
|
|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: 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.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
|
|