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


Joined: 16 Feb 2001
Posts: 57

PostPosted: Fri Dec 20, 2002 3:41 am   

Pattern Matching - Fixed Length String
 
Is there an easy way to match a fixed length "string" that can be made up of two characters.

Something like..
XXXXXXAAAAAAA
XXXXXXXXXXXXX
AAAAAAAAAAAAA

The X's will always come before the A's. I don't care what they are (if they are X or A's) I'm just matching it.

Right now I'm just using a string of X's because I'll always see full X's, but for other people, they might see X's and A's.

I can only think of using a bunch of ?'s or a bunch of {A|X}'s.

This isn't really that important but I'm just curious how someone else would do it.
Reply with quote
Drevarr
Beginner


Joined: 19 Dec 2001
Posts: 17
Location: USA

PostPosted: Fri Dec 20, 2002 4:30 am   
 
#trigger {([XA])} {#if %len( %1)=13 {#Show Matched the line}}
Reply with quote
HariKari
Wanderer


Joined: 16 Feb 2001
Posts: 57

PostPosted: Fri Dec 20, 2002 7:53 am   
 
Anybody know how efficient that would be? But I guess that isn't that big of an issue with faster computers/faster zMUD 6.40
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri Dec 20, 2002 1:59 pm   
 
I devised a quick test for this. First I created three triggers, one for each method:
#TRIGGER {(?????????????)} {#ADD test 1}
#TRIGGER {({X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A}{X|A})} {#ADD test 1}
#TRIGGER {([XA])} {#IF (%len(%1) = 13) {#ADD test 1}}

Then, I created a text file in which the first and last line were both:
#SH %secs

In between those two lines there were a bunch of #SH's. The upper block and lower block of #SH's contained a sentence that would not be matched by the triggers. While the middle block of #SH's contained:
XXXXXXAAAAAAA

I then put this file in the zMUD folder and disabled both of the other triggers except the one I wanted to test (this was done in a blank window in which the only triggers were the three I created) and entered:
#VAR test 0;#READ speedtest.txt

This was repeated again for the other two (keeping always the ones not to be tested disabled).

Anyway, this is just in case you wanted to reproduce the test yourself. In the end, I obtained a difference between the last and first %secs for each one as follows:
Trigger 1 - 942ms
Trigger 2 - 831ms
Trigger 3 - 1002ms

So, it appears that the second method (13 {X|A}'s) is the faster one.

Kjata
Reply with quote
HariKari
Wanderer


Joined: 16 Feb 2001
Posts: 57

PostPosted: Sat Dec 21, 2002 8:17 am   
 
Ok, thanks for the testing info.

I was thinking that specific data would be faster than using variables, but I wasn't too sure.

Thanks again.
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