 |
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: 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. |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Sep 29, 2007 8:19 pm |
Just put brackets round the whole pattern and use %1 or a local variable.
|
|
|
 |
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: 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?
|
|
|
 |
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: 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. (*) ?
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
 |
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: 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. |
|
|
 |
|
|