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
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4772
Location: Pensacola, FL, USA

PostPosted: Sat Feb 21, 2009 7:58 am   

Text insertion
 
Is there a better way to insert text into mud output other than the following?

#TR {({rolaren|vultite})} {#SUB {%params (+20)}}
_________________
Discord: Shalimarwildcat
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Feb 21, 2009 8:05 am   
 
Depends what exactly you're trying to do - you might find #sayadd useful.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4772
Location: Pensacola, FL, USA

PostPosted: Sat Feb 21, 2009 8:52 am   
 
I want the text to appear immediately after the pattern, not at the end of the line.
_________________
Discord: Shalimarwildcat
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Feb 21, 2009 9:49 am   
 
Then yeah, #sub is what you want. You could read up on regex lookahead and lookbehind for ways of matching without matching, though - basically, you put your pattern in a lookbehind, like so:

#regex {(?<=(?:rolaren|vultite))} {#sub " (+20)"}

And the "match" of this pattern is a zero-length string (like if the pattern was blank) but that must be preceded by rolaren or vultite (the contents of the (?<=blah) construct). Yeah, this explanation sucks - I've linked to the relevant pages on the web at the bottom of this post.

This might screw up CMUD's colour coding because you're substituting a zero-length string with a non-zero length string, but it probably won't - if it does, you could add a space to the end of the pattern and another to the end of the substitute string.

You might also want to consider using \b before and after the pattern, if applicable.

See also (1, 2)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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