|
etz Newbie
Joined: 09 Mar 2005 Posts: 2
|
Posted: 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 |
|
|
|
Spartacus Wanderer
Joined: 23 Apr 2001 Posts: 53 Location: USA
|
Posted: 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:
In your second example, it should produce:
|
|
_________________ Spartacus
rm -rf .* |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: 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." |
|
|
|
etz Newbie
Joined: 09 Mar 2005 Posts: 2
|
Posted: Thu Mar 17, 2005 5:12 pm Thanks |
Thanks for the timely help. That works nicely.
etz |
|
|
|
|
|