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
Jeo
Newbie


Joined: 14 Jun 2004
Posts: 3

PostPosted: Mon Jun 14, 2004 9:13 pm   

Matching whole word in trigger.
 
I want to make color triggers for specific players' names. One of these names is Ral. The problem with this, is that Ral is a common string in larger words (neutral, emerald, etc.). Is there a way to match the pattern only if it is a whole word, or if it is followed by a word delimiter? Possible examples that I can think of are:
Ral
Ral(
Ral,
These could fall either at the beginning of the line, or somewhere in the middle. Also, capitalization could vary, such as RAl, rAl, or RaL.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jun 14, 2004 9:39 pm   
 
Use %p or %q to mark the beginning and end of your word.
%p match any punctuation
%q match any punctuation (same as %p but matches start and end of line)
Reply with quote
Jeo
Newbie


Joined: 14 Jun 2004
Posts: 3

PostPosted: Mon Jun 14, 2004 9:53 pm   
 
If I make my trigger pattern %qRal, it fires on 123abcRal no matter if it's at the beggining of the line or not. I want it to only fire if Ral is at the beginning of the line followed by a space or delimiter, or anywhere else in the line as long as it is followed and preceded by a space or delimiter.
ex: Ralph said hello to Ral. --> no part of Ralph should be colored, but Ral at the end should be.
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Jun 14, 2004 10:01 pm   
 
Make the trigger case sensitive and follow it with %q (in this case, Ral%q). I use this all the time.
Reply with quote
Jeo
Newbie


Joined: 14 Jun 2004
Posts: 3

PostPosted: Mon Jun 14, 2004 10:12 pm   
 
The trigger cannot be case sensitive due to the possibilty of random caps (Ral, rAl, RAL, etc.) I found that I can do:
^%pRal%p to catch Ral at the beginning of a line, and
%pRal%p to catch Ral anywhere else.

Can I combine these somehow into one trigger? I tried {^%pRal%p|%pRal%p} but that doesn't work. Any suggestions? Or am I just stuck making 2 triggers?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4772
Location: Pensacola, FL, USA

PostPosted: Tue Jun 15, 2004 4:58 am   
 
i think it is possible if you write a Perl regular expression trigger... but im not familiar enuff with the syntax to be sure.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Jun 15, 2004 3:17 pm   
 
Although the test tab may show 123abcRal, I don't think that 123abc will match %q. If any of those 6 characters match %q, it's a bug and you should submit a bug report.
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