|
Zafrusteria Wanderer
Joined: 11 Oct 2000 Posts: 94 Location: United Kingdom
|
Posted: Sun Feb 29, 2004 10:20 am
problem with =~ |
#alias test_bug
#IF ("%1" =~ "foobar") {#SHOW true foobar = "%1"}
#IF ("%1" =~ "true foobar") {#SHOW true true foobar = "%1"}
#IF ("%1" =~ "false foobar") {#SHOW true false foobar = "%1"}
when run with: test_bug "true foobar"
The output is this, can anyone explain why?
true foobar = true foobar
true true foobar = true foobar
true false foobar = true foobar
From the Help text "v1 =~ v2 true if the string v1 matches the pattern in v2
"
Clearly in the example above v1="false foo bar" should not match with v2="true foobar" |
|
|
|
Zafrusteria Wanderer
Joined: 11 Oct 2000 Posts: 94 Location: United Kingdom
|
Posted: Sun Feb 29, 2004 10:40 am |
also this seems wrong too but using an exact match
alias test_bug
#SHOW %1
#IF ("%1" = "monster") {#SHOW buggy} {#SHOW correct}
#IF ("%1" = "a") {#SHOW buggy} {#SHOW correct}
run with test_bug "a monster"
Output is
a monster
buggy
buggy
Again how can "a monster" be equal to "a" and "monster".
this is even more bazar
call with test_bug "a fred"
get the output
a fred
buggy
buggy
not sure how "fred" = "monster" |
|
|
|
m_orb Beginner
Joined: 13 Jan 2003 Posts: 28
|
Posted: Sun Feb 29, 2004 1:56 pm |
use "%-1" in place of "%1" while testing a couple of words
#IF ("%-1" =~ "true foobar") {#SHOW true true foobar = "%-1"}
and test without quotation marks:
test_bug true foobar |
|
|
|
Zafrusteria Wanderer
Joined: 11 Oct 2000 Posts: 94 Location: United Kingdom
|
Posted: Sun Feb 29, 2004 2:22 pm |
Thanks for the answer,
I found it in the help file too |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Mar 01, 2004 4:44 am |
Also you should understand that quotes and braces are included in the arguments of alias.
#AL Example {#ECHO %char(%ascii("%1"))}
Example "a"
returns: "
Example {a}
returns: {
If you remove the quotes in the alias then the parser will strip whatever delimeter was used when calling the alias.
#AL Example {#ECHO %char(%ascii(%1))}
Example "a"
returns: a
Example {a}
returns: a |
|
|
|
|
|