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


Joined: 13 Nov 2006
Posts: 3
Location: Denmark

PostPosted: Mon Nov 13, 2006 4:53 pm   

Pattern matches all or no strings
 
I want to check wether a variable matches one of two strings, like this:

#IF {@bdiv =~ "Alliance Army"} {#SAY AA}
#IF {@bdiv =~ "Alliance Navy"} {#SAY AN}

That is the syntax I can find in the help pages, but it just doesn't work. I have checked the @bdiv variable, and it actually contains one of the strings at any given time, but nothing happens.

If I remove the quotation marks, the statement returns true in both cases.

Does anyone have a suggestion?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Nov 13, 2006 5:49 pm   
 
Hmmm, I'm at work so I can't actually check the syntax, but I did notice two things.

First, since your variable can contain spaces you probably need to quote it so that match is successfully performed.

#IF {"@bdiv" =~ "Alliance Army"} {#SAY AA}
#IF {"@bdiv" =~ "Alliance Navy"} {#SAY AN}

I also noticed that since you're not actually using any pattern matching in your string, you can do a direct comparison.

#IF {"@bdiv" == "Alliance Army"} {#SAY AA}
#IF {"@bdiv" == "Alliance Navy"} {#SAY AN}

I hope that helps.
_________________
Asati di tempari!
Reply with quote
seyalas
Newbie


Joined: 13 Nov 2006
Posts: 3
Location: Denmark

PostPosted: Mon Nov 13, 2006 8:42 pm   
 
The second suggestion worked! Thanks :)
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