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


Joined: 26 Aug 2002
Posts: 17
Location: USA

PostPosted: Wed Dec 10, 2003 2:41 am   

Pattern Matching
 
Here is the line I'm trying to get a trigger to fire on:

Str :[319/171] Int :[274/167] Wis :[165/ 67] Hr :[452]

Keeping in mind that if a number is only 2 digits, it has a space before it, as demonstrated above in "Wis :[165/ 67]".

I'm trying to find the right sequence of wild card expressions, etc., to match that line. I've tried using %s to match white space, but apparently if you use %s, atleast ONE space of white space has to exist for the pattern to work. I really don't want to have to create seperate triggers for each possibility where the number could be 2 digits vs. 3 digits, but I've exhausted all my ideas of how to use pattern matching wildcards, etc. Any help would be appreciative!

TIA.
Reply with quote
Toetag
Magician


Joined: 10 Oct 2000
Posts: 356
Location: USA

PostPosted: Wed Dec 10, 2003 2:50 am   
 
Trigger:

Str :~[(%d)/(%d)~] Int :~[(%d)/(%d)~] Wis :~[(%d)/ (%d)~] Hr :~[(%d)~]
Reply with quote
kinson
Beginner


Joined: 26 Aug 2002
Posts: 17
Location: USA

PostPosted: Wed Dec 10, 2003 3:02 am   
 
I guess I wasn't completely clear. The trigger needs to able to match each of those numbers regardless of if there are two digits or three digits. That part could have easily been:

Wis :[165/165]

In which case, Wis :~[(%d)/ (%d)~] would not have matched it. I need some way to have the trigger recognize the number, and get rid of anything before it, if there is anything in front of it at all, like a space.
Reply with quote
Toetag
Magician


Joined: 10 Oct 2000
Posts: 356
Location: USA

PostPosted: Wed Dec 10, 2003 3:06 am   
 
Ahh, didn't realize the space after the / was for the 3rd digit. Gimme a few and we'll have that fixed as well.
Reply with quote
Toetag
Magician


Joined: 10 Oct 2000
Posts: 356
Location: USA

PostPosted: Wed Dec 10, 2003 3:17 am   
 
Trigger:
Str :~[(*)/(*)~] Int :~[(*)/(*)~] Wis :~[(*)/ (*)~] Hr :~[(*)~]

value:
maxSTR=%trim(%1)
STR=%trim(%2)
maxINT=%trim(%3)
INT=%trim(%4)


etc.


This worked offline using:
#SHOW Str :[319/ 71] Int :[274/ 67] Wis :[ 65/ 67] Hr :[452]
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Dec 10, 2003 8:51 pm   
 
Another solution is a user-defined wildcard which includes all the digits and a space. The minus sign, plus sign, comma, and period can also be included if there's a possibility they'll be needed. Not as convenient as the predefined wildcards, but easily done.
[0-9 ]
[0-9 ~-+,.]
NOTES:
Since - is used to indicate a range, you MUST put the quote character ~ before it to include it in the wildcard.
For repeated use, I usually type the wildcard once, then copy it to the clipboard and use CTRL-V to paste it where needed.

Your pattern would be:
Str :~[([0-9 ])/([0-9 ])~]%sInt :~[([0-9 ])/([0-9 ])~]%sWis :~[([0-9 ])/([0-9 ])~]%sHr :~[([0-9 ])~]
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