|
Bajed Novice
Joined: 15 Aug 2004 Posts: 33
|
Posted: Wed Jan 04, 2006 12:47 am
Perl Regular Expression + Ansi Trigger |
Is it possible to use both of these at the same time? My trigger doesn't seem to be firing at all, here is the pattern:
\e[1;32m\((?:Channel1|Channel2)\): (@MyFriends) says, ".+\."
this should fire whenever I get a line like this:
(Channel1): John says, "Hey there Bajed!" and is in green. The trigger isn't working though! Any ideas? |
|
|
|
Bajed Novice
Joined: 15 Aug 2004 Posts: 33
|
Posted: Wed Jan 04, 2006 12:50 am |
Err, I used an exclamation point at the end of my example, but it doesnt work with a period either :P
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Wed Jan 04, 2006 2:06 am |
No zMud active but your ?: syntax doesn't appear to be correct.
|
|
|
|
Bajed Novice
Joined: 15 Aug 2004 Posts: 33
|
Posted: Wed Jan 04, 2006 2:10 am |
It works fine without the ansi stuff, and with the Ansi Trigger option unchecked, heh. (?:...) in regex means to group the contents, but don't capture. which is what I want.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Wed Jan 04, 2006 5:20 am |
The problem is that regex uses a different format to match ANSI.
The best way I can explain it is for you to create a trigger and tick ANSI colour but -don't- select regex, then highlight an example line in the MUD of what you want to match, paste it into your trigger, and click the "convert" button. That will convert all of the colours to the proper format and you can then fix your pattern to match the correct text. |
|
|
|
Bajed Novice
Joined: 15 Aug 2004 Posts: 33
|
Posted: Wed Jan 04, 2006 5:25 am |
Ah ok, that works, weird format...
Anyway, this leads me to another questin. It seems I can't use ansi codes in an (?:....), is this true? For example, Channel1 is yellow and Channel2 is blue. I tried doing this in both a normal trigger and its equivalent (now that I know) regex, but neither work:
^\((?:%e[30mChannel1|%e[31mChannel2)\) but it doesnt seem to match either "%e[30mChannel1" or "%e[31mChannel2" ... do the ansi sequences HAVE to come at the very beginning of the trigger? Hrm |
|
|
|
|
|