|
Vittorio Beginner
Joined: 22 Oct 2003 Posts: 10
|
Posted: Fri Dec 12, 2003 5:42 pm
More questions about functions. |
Strangeness. It doesnt quite behave as I expect it to.
I defined a function as follows:
#VAR test {%if( %1=~ "cat", %1, 0)} {_nodef}
Basically i'm trying to pattern match the letters "cat" from the parameter passed to @test().
@test(cat) = cat (true - expected)
@test(catnip) = catnip (true - expected)
@test(dog) = 0 (false - expected)
@test(no kitty) = no kitty (true!?)
Why the heck is the last example a match? Everything returns true if I pass anything longer than one word as a parameter. Does pattern matching not work in this case or something?
I understand I can use %pos to avoid the aforementioned problem in the example. However, I would like to pattern match using wildcards, so =~ is preferable.
-V. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Dec 12, 2003 7:10 pm |
#FU test {%if( "%1" =~ "cat", "%1", 0)}
|
|
|
|
|
|
|
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
|
|