|
bortaS Magician
Joined: 10 Oct 2000 Posts: 320 Location: Springville, UT
|
Posted: Sat Dec 10, 2005 8:11 pm
Trigger pattern with special chars |
I'm trying to capture a channel on a MUD. I got part of the trigger working correctly, but the @ symbol is throwing it off. The line I'm trying to caputer looks like this:
[imud_gossip@I3] Person@SomeMUD says, 'Yeah, right!'
This is actually fairly easy, except that the @I3 is making it harder than it needs to be. Normally this would work:
^.*~[imud_gossip~@I3~]
But that doesn't work in this case, and I dunno why. I also tried a regular expression, but the regex that I get from my tools don't work with the perl regex in zMUD. I'm baffled. Can somebody lend me a hand? |
|
_________________ bortaS
~~ Crusty Klingon Programmer ~~ |
|
|
|
luggage Novice
Joined: 20 Jul 2004 Posts: 38 Location: Australia
|
Posted: Sun Dec 11, 2005 4:31 am |
Hrm. If you read the help file on regex, it tells you (in another colour too) that the prefix for @ should be a '~' instead of a '\' in zmud to stop zmud parsing a variable.
Therefore this works on mine in perl regex:
#TRIG {[imud_gossip~@I3] } {#SHOW triggered!}
Luggage |
|
|
|
bortaS Magician
Joined: 10 Oct 2000 Posts: 320 Location: Springville, UT
|
Posted: Sun Dec 11, 2005 5:24 am |
Yes, I read the help file, and yes, I already know that the tilde (~) is the escape character. It is not working, and that's why I came here for help. All of my regex testing tools work with this perl regex:
^(.*)[imud_gossip@I3](.*)
This is a valid perl regex, but it doesn't work with either escaping or not escaping the @ symbol with either a \ or ~. @I3 is not a variable, it is part of the line I'm trying to capture.
Any more suggestions? |
|
_________________ bortaS
~~ Crusty Klingon Programmer ~~ |
|
|
|
Slaem Apprentice
Joined: 20 Sep 2005 Posts: 135
|
Posted: Sun Dec 11, 2005 10:43 am |
How 'bout matching a single character where the @ normally is. Something like,
#TR {~[imud_gossip?I3~]}
(no zmud to test att) |
|
|
|
bortaS Magician
Joined: 10 Oct 2000 Posts: 320 Location: Springville, UT
|
Posted: Sun Dec 11, 2005 3:42 pm |
Yes, that worked! The final pattern ended up being:
~[imud_gossip?I3~](*)
Thanks, Slaem! |
|
_________________ bortaS
~~ Crusty Klingon Programmer ~~ |
|
|
|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Sun Dec 11, 2005 4:36 pm |
A more restrictive solution that should work for you is a regex pattern of:
^(.*)[[]imud_gossip[@]I3](.*)
Tested using 7.20b with your sample text
[imud_gossip@I3] Person@SomeMUD says, 'Yeah, right!'
The double "[" is not a typo.
Why did you want to have a start of line anchor next to an optional wildcard? You'd probably be better off ditching the "(.*)" at the beginning if all of the text you want to catch looks like your sample.
-Tarn |
|
|
|
bortaS Magician
Joined: 10 Oct 2000 Posts: 320 Location: Springville, UT
|
Posted: Sun Dec 11, 2005 6:39 pm |
Quote: |
Why did you want to have a start of line anchor next to an optional wildcard? You'd probably be better off ditching the "(.*)" at the beginning if all of the text you want to catch looks like your sample. |
Because there is some other text before the text I want, but not always. |
|
_________________ bortaS
~~ Crusty Klingon Programmer ~~ |
|
|
|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Tue Dec 13, 2005 3:28 pm |
bortaS wrote: |
Quote: |
Why did you want to have a start of line anchor next to an optional wildcard? You'd probably be better off ditching the "(.*)" at the beginning if all of the text you want to catch looks like your sample. |
Because there is some other text before the text I want, but not always. |
Then the leading anchor ("^") is pointless- but I now see that you didn't include it in the final version anyway.
-Tarn |
|
|
|
|
|