|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Wed May 05, 2010 3:03 pm
regex trigger help |
I have a trigger set up to squelch the prompt character from my display. It worked fine in 2.37 but now that I've ported my code to 3.16 a change to the way CMUD handles MXP caused this script to break.
Basically, my mud uses non-standard MXP tags, so the MXP triggers I had set up for things like <experience>%n</experience> in 2.37 stopped firing in 3.16. I changed them to pattern triggers instead. The problem is that the mud occasionally sticks a prompt character '>' in front of a line. Now sometimes my prompt squelching trigger catches these tags (but not consistently) and strips out the '>' from the opening tag, which causes it to display like this instead instead: <experience325346</experience>
This is my regex trigger:
^[>?](.*)$
And this is the code behind it:
#GAG
#SHOW %remove(">", %-1)
I don't use #SUB because I need other triggers (highlighting in particular) to process on the line after it is redisplayed.
Can I get a little assistance in making this trigger NOT fire when there's a <tag>%1</tag> in the line?
Thanks in advance. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed May 05, 2010 3:18 pm |
You mean like this?
><experience>12345</experience>
Can't you just do this:
^>?<experience>\d+</experience> |
|
|
|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Wed May 05, 2010 3:24 pm |
No, that's the exact opposite - I don't want this prompt squelching trigger firing at all when there's a tag in the line.
Sorry if I was unclear. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed May 05, 2010 3:30 pm |
So just anchor the start of the line ^<experience then it won't.
Meaning...
^<experience>\d+</experience>
will never fire on
><experience>12345</experience>
but will on
<experience>12345</experience>
unless you mean that <experience>12345</experience> is stuck in the middle of the whole line?
In that case use
\b<experience>\d+</experience>\b |
|
|
|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Wed May 05, 2010 3:45 pm |
I think I lost ya. The problem isn't with my tag-catching triggers, the faux MXP tag triggers work fine. The prompt squelching trigger also works fine on lines that display without tags in them, such as the following:
>Something happens here.
becomes:
Something happens here.
The issue I'm having is that the prompt squelcher is grabbing the angle brace character in some of those tags and removing it. So:
><experience>347896</experience>
becomes:
<experience347896</experience>
This happens with any tag that happens to land after a prompt character; <rt>, <st>, <ut>, <vitality>, etc, not just <experience>. I'm just using that one as an example. I just want to avoid having tags broken by this trigger. Theoretically, none of the tags should break because I use the BOL anchor in the squelch trigger already and for some reason it's still eating the angle brace inside the tags. The following is the current prompt-catching trigger:
^[>?](.*)$ |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed May 05, 2010 4:11 pm |
Why do you have > inside of a character class?
The other problem is you are not capturing the first > you are capturing the one after it by using ^[>?](.*)$
%1 is everything after the opening > and you are replacing the > after the opening one.
Just use a substitute to get rid of the opening >.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger priority="10" regex="true" copy="yes">
<pattern>^></pattern>
<value>#substitute ""</value>
</trigger>
</cmud>
|
Then it will still trigger on the remaining line. |
|
|
|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Wed May 05, 2010 4:31 pm |
<facepalms>
You nailed it, now. Prior to the move to 3.16 it grabbed the prompt as well and removed it. I had only added the [>?] in an attempt to further improve the logic and now it looks like I can remove the %remove() function.
Now I feel like an idiot! hahaha |
|
|
|
|
|