Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: 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 ~~
Reply with quote
luggage
Novice


Joined: 20 Jul 2004
Posts: 38
Location: Australia

PostPosted: 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
Reply with quote
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: 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 ~~
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: 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)
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
Reply with quote
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: 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 ~~
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: 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
Reply with quote
bortaS
Magician


Joined: 10 Oct 2000
Posts: 320
Location: Springville, UT

PostPosted: 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 ~~
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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