|
seyalas Newbie
Joined: 13 Nov 2006 Posts: 3 Location: Denmark
|
Posted: 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? |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: 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! |
|
|
|
seyalas Newbie
Joined: 13 Nov 2006 Posts: 3 Location: Denmark
|
Posted: Mon Nov 13, 2006 8:42 pm |
The second suggestion worked! Thanks :)
|
|
|
|
|
|