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
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 7:22 pm   

Is there something like %trigger that is all the text that a trigger matched?
 
Predefined variables:
%trigger the line that caused the last trigger

Is there something similar for not the whole line, but just the entire text that the trigger matched? This would be very useful. For example, I have lots of triggers like this:
a blue and black key with purple spots({.|})$

OK, I made that one up, but the point is: I have to match an optional full stop at the end, and capture whether it was there or not, if I want to use a #SUB that adds some text to the end of the line.

And {.|} isn't working in v2.04, and probably slows my triggers down.

Hmm, OK, I just realised that I could probably use %trigger or %line instead within my SUB in this case. But the question still stands. There are other useful cases, like if I wanted to add my SUBed text before the text that was matched by the trigger, or if my trigger text didn't match the end of a line.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Sep 29, 2007 8:19 pm   
 
Just put brackets round the whole pattern and use %1 or a local variable.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 8:51 pm   
 
Ah, well, I discovered you could nest brackets (parentheses) inside each other. That's neat. And undocumented! (And works in zMUD too.) I wonder if putting parentheses around the whole text is as efficient as a predefined variable though?
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 8:58 pm   
 
Putting %1 in the pattern is also undocumented, although I've been using that since I first started using zMUD. I'm not entirely clear what it's supposed to be equivalent to though. (*) ?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Sep 29, 2007 9:02 pm   
 
Apparently it's equivalent to the regex (.+). But I'd rather just use a real wildcard.

And yes, you can nest parenthesis, and have them anywhere you like. They're numbered based on the position of their opening bracket.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sun Sep 30, 2007 1:27 am   
 
Fang Xianfu wrote:
And yes, you can nest parenthesis, and have them anywhere you like. They're numbered based on the position of their opening bracket.

Yeah, I figured that out by testing.
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