 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4772 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Feb 21, 2009 8:05 am |
Depends what exactly you're trying to do - you might find #sayadd useful.
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4772 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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) |
|
|
 |
|
|