Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Sun Jul 01, 2007 2:14 pm   

[CMUD 1.34] Pattern doesnt work
 
Hello i have a list with variables and i want to do a regexp with =~ and doesnt work :S

#ec 1 %1
$one = ""+%word( %1, 1)+""
$p = "{"+{@nicks}+"}"
#ec $one $p
#if ($one =~ "%s" + @nicks + "%s" ) {#ec ok} {#ec nook}

it doesnt matter what I put in %1 it is always ok
testea 1
1 1
1 {one|two|three}
ok

testea 2
1 2
2 {one|two|three}
ok
testea one
1 one
one {one|two|three}
ok
Reply with quote
Fuego Ledrey
Wanderer


Joined: 09 May 2007
Posts: 64
Location: Dustin Acres, California

PostPosted: Sun Jul 01, 2007 2:58 pm   
 
If I understand what you are trying to do, then this:
Code:
#ec 1 %1
$one = %1
$p = {@nicks}
#ec $one $p
#if (%ismember($one,$p)) {#ec ok} {#ec nook}

should fix your problem.
Alternately you could not use local variables and just do:
Code:
#ec 1 %1
#ec %1 @nicks
#if (%ismember(%1,@nicks)) {#ec ok} {#ec nook}


If this isn't what you wanted could you tell me what you are trying to accomplish?
_________________
EDIT: Image moved to Avatar FINALLY.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jul 01, 2007 3:08 pm   
 
+ is only a concatenation inside an expression.

$one = ""+%word( %1, 1)+""

won't concat but

$one = %eval(""+%word( %1, 1)+"")

will and

$one = (""+%word( %1, 1)+"")

probably will. Make your concats explicit. This is also the problem with the #if afterwards. You can also use the %concat function.

Though why you're concatenating a word with two blank strings, I don't know.

EDIT: Ninjad :(
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Sun Jul 01, 2007 7:39 pm   
 
i can use the ismember ... but i have to lower all nicks and things to compare ... and how can i do it with variables in list? .... change before add it? do the ismember ignorecase? ....

the problem is how to use a pattern with a string list ....
it is an alias called testea
#ec 1 %1
$one = %word( %1, 1)
#ec $one @varis
#if ($one =~ {@varis} ) {#ec ok} {#ec nook}
this shows always nook :S

testea one shows
1 one
one one|two|three
nook

edited to say that i want to add spaces because i have more nicks that have spaced before and after .... (but i can trim them ... so there is not much problem for this) the problem is that i want to do doesnt work .... the ismember function but with =~ in order to have ignorecase (and to know why it doesnt work :D)

testea 1 shows
1 1
one one|two|three
nook
Reply with quote
Fuego Ledrey
Wanderer


Joined: 09 May 2007
Posts: 64
Location: Dustin Acres, California

PostPosted: Sun Jul 01, 2007 8:10 pm   
 
Even if ismember doesn't ignore case, you could through in a %lower in there, something like:
Code:
%ismember($one,%lower($p))

I can't check right now cause my mouse just broke, but I'm trying to resolve that problem, heh. Yay for keyboard shortcuts Rolling Eyes
_________________
EDIT: Image moved to Avatar FINALLY.
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Sun Jul 01, 2007 9:46 pm   
 
but why doesnt work the =~ with string list? it is not the lower function .......
with the zmud it worked perfeclty
Reply with quote
Fuego Ledrey
Wanderer


Joined: 09 May 2007
Posts: 64
Location: Dustin Acres, California

PostPosted: Sun Jul 01, 2007 9:50 pm   
 
I've never used the "=~" before, but I assume it was one of those "bugs" in zMUD that has been fixed in CMUD.
_________________
EDIT: Image moved to Avatar FINALLY.
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Sun Jul 01, 2007 10:33 pm   
 
you can search for =~ in help .... it is to do a trigger comparition .... but doesnt work and it is supposed to do ...
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jul 01, 2007 10:50 pm   
 
It'd really help if I had an example of the value of @nicks and of %1 in that script. At the moment I have the vaguest of ideas what it's doing.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Sun Jul 01, 2007 10:58 pm   
 
see my posts ..

#ec 1 %1
$one = %word( %1, 1)
#ec $one @varis
#if ($one =~ {@varis} ) {#ec ok} {#ec nook}
this shows always nook :S

%1 = one
nicks or varis .... {one|two|three}

testea one shows
1 one
one one|two|three
nook
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jul 02, 2007 12:34 am   
 
%ismember is case sensitive, just so you know, but Feugo's solution gets round that. As for your problem, I've finally gotten access to CMUD and I've been able to test out a few of these things. I thought the problem would still be implicit concatenation, since you mean the {} characters in your pattern to be literal, but the variable reference not to be. I tried this:

$one = %word(%1,1)
$pattern = %concat("{",@varis,"}")
#if ($one =~ $pattern) {#ec ok} {#ec nook}

but CMUD complained that the $ character was illegal in the expression. I finally managed to get this, which worked:

$one = %word(%1,1)
$pattern = %concat("{",@varis,"}")
#if ($one =~ {$pattern}) {#ec ok} {#ec nook}

everything else I tried failed. There might be a bug here in CMUD's insistence that all sorts of characters were invalid in the expression (it didn't like when I tried to do the %concat inside the expression either) but that might also be particular to the =~ operator. At least it's working now :)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Fuego Ledrey
Wanderer


Joined: 09 May 2007
Posts: 64
Location: Dustin Acres, California

PostPosted: Mon Jul 02, 2007 12:42 am   
 
Go Fang! It's good to know that ismember is case sensitive.
_________________
EDIT: Image moved to Avatar FINALLY.
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Mon Jul 02, 2007 9:59 am   
 
Perfect Fang :D
My solution at the end gets as this

$one = %concat(" ",%word(%1,1)," " )
#ec one $one
$pattern = %concat("%s{",@varis,"}%s")
#ec pattern $pattern
#if ($one =~ {$pattern}) {#ec ok} {#ec nook}

(without the #echo) It is in order to colour nicks ... with one trigger {@varis} #cw blue
the %s is because we have nicks that are composed like one or aone .... and with the pattern you have put ... one or aone are the same ... but now it works :D (thx)

with this it works too :D
$one = " "+%word(%1,1)+" "
#ec one $one
$pattern = "%s{" + @varis + "}%s"
#ec pattern $pattern
#if ($one =~ {$pattern}) {#ec ok} {#ec nook}

so the problem i have had .. is that i didnt put the {} in #if ... so many thx
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jul 02, 2007 5:17 pm   
 
I'll add this to the bug list. You shouldn't need to put {} around $pattern, so that's definitely a bug. Not sure about the original post. Since the =~ is already occurring within an expression, then using the + for concat should have worked.

Anyway, I have reproduced the problem. And right now it seems that the =~ expression is really broken.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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