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
etz
Newbie


Joined: 09 Mar 2005
Posts: 2

PostPosted: Thu Mar 17, 2005 3:58 pm   

Are special chars in the pattern the problem?
 
I am sure most of you guys will laugh at my inexperience, and yes, I have searched the forums for some info however *cough* prolly brackets give the same problem also there *cough* ... er... here goes:

#var tmp_1 {(road).}
#var tmp_2 {"A bend in the street (road)."}
#say @tmp_1
#say @tmp_2
#say %match(@tmp_2,@tmp_1)
#unvar tmp_1
#unvar tmp_2

does not match (returns 0) while this does (!)...

#var tmp_2 {"A bend in the road."}
#say @tmp_2
#say %match(@tmp_2,"~(road~)")
#unvar tmp_2


So, I am not sure how to match "(road)".

Thanks for your help.

etz
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Thu Mar 17, 2005 4:58 pm   
 
Why not use %regex instead?

Seems to me like you're wanting to match "(road)" within a room name which would be stored in @tmp_2. This ought to do that for you.

Code:
#unvar mLength
#say %regex(@tmp_2,"\(road\)",mLength)
#say @mLength


In your first example, this should produce:
Code:
22
6


In your second example, it should produce:
Code:
0

_________________
Spartacus
rm -rf .*
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Thu Mar 17, 2005 5:06 pm   
 
I cant work it out with match
but this will do a literal match with any string in @tmp_1
Code:
 %regex(@tmp_2,<%subregex(@tmp_1,"([\\^\.\$\|\(\)\[\]])","\%1")>)
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
etz
Newbie


Joined: 09 Mar 2005
Posts: 2

PostPosted: Thu Mar 17, 2005 5:12 pm   Thanks
 
Thanks for the timely help. That works nicely.

etz
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