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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Levine
Newbie


Joined: 08 Jan 2007
Posts: 3
Location: Ontario, Canada

PostPosted: Tue Feb 06, 2007 5:57 am   

Is this a bug, or am I losing it?
 
I've been trying to figure out why this won't work,

Pasted into the zMud command window, works as expected:
Code:
#ECHO %subregex( "apple orange grape", "\w+ (\w+) \w+", %1)
returns "orange" .. just the way I want it to.

This however does not work,
Code:
#alias test { #ECHO %subregex( "apple orange grape", "\w+ (\w+) \w+", %1) }
now if I execute "test" I get nothing.

To make things more interesting, let's replace the 'test' alias with this:
Code:
#alias test { #ECHO %subregex( "apple orange grape", "\w+ (\w+) \w+", "foobar") }
Now when I execute the 'test' alias, I get "foobar" returned.

So i'm thinking capturing paranthesis works when used outside an #alias but not when used within an #alias.

Can anyone tell me if i'm missing something here, or is this a bug?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Feb 06, 2007 6:30 am   
 
Yes, this is one of those annoying zMUD things. The alias really is working - it's replacing the string with %1; that is, the first parameter of the alias, which is empty. You're not getting nothing, you're getting a blank line. You need to delay the expansion of %1 so it's ignored by the alias parsing, giving you:

#alias test {#ECHO %subregex( "apple orange grape", "\w+ (\w+) \w+", %%1)}

which works fine for me.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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