 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4718 Location: Pensacola, FL, USA
|
Posted: Wed Dec 29, 2010 1:09 pm
%match not always matching |
Code: |
<alias name="yo" id="62">
<value>#LOCAL $yo
#IF (%match( "hi", "hi", $yo)) {
#IF ($yo) {#SAY $yo}
#SAY yo-ho
}
$pattern=yo
#IF (%match("yo", $pattern, $yo)) {
#IF ($yo) {#SAY $yo}
#SAY yo-ho-ho
}
$pattern=yo|to|no no|bo
#IF (%match("yo", "{$pattern}", $yo)) {
#IF ($yo) {#SAY $yo}
#SAY yo-ho-ho and a bottle of rum
}</value>
</alias> |
For some reason I cant get a match when using a $localVar stringlist in the pattern.
Also, since the pattern matches starting with the first char, shouldn't $yo=1 instead of 2? Or am I looking too close. |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Dec 29, 2010 1:26 pm |
"{$pattern}" is a string--$pattern is not expanded. What you need is: %concat("{",$pattern,"}")
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Dec 29, 2010 1:32 pm |
The %match will _return_ a 1, but $yo will not be changed because you are not capturing any values in your pattern.
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4718 Location: Pensacola, FL, USA
|
Posted: Wed Dec 29, 2010 1:47 pm |
figured my own answers... since i have no () its going on pattern length, so 2 is right, and i just need to %concat in the $pattern to make it work:
%concat("({", $pattern, "})") |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4718 Location: Pensacola, FL, USA
|
Posted: Wed Dec 29, 2010 1:48 pm |
serves me right for not refreshing first... heh
|
|
_________________ Discord: Shalimarwildcat |
|
|
 |
|
|