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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Thu Aug 14, 2014 3:38 pm   

Trigger and Parentheses
 
Hi

I have this trigger:

Code:
^You still have to kill ~* (*) ~((*)~)$


And it has always work for me untill the mud send me this output:

Code:
You still have to kill * a Dragon Gladiator (Cell B1B (Upper))
You still have to kill * a Tiny Little Menehune (Cell block B (Lower Back))
You still have to kill * a halfling refugee (A Halfling Refugee Camp)
You still have to kill * a passeher (Lost in Golden Sands)
You still have to kill * a blue and gold macaw (In the high branches of a mulberry tree)
You still have to kill * a Naked Gang Member (Cell B2F (Lower))


How do I make the trigger capture the lines with the extra parentheses ?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Aug 14, 2014 11:40 pm   
 
The pattern matching helpfile will be handy for reference, but if * doesn't match the output (I'm actually surprised it doesn't) you can use a range pattern. Range patterns (in regex, I believe they're referred to as character sets) allow you to explicitly specify which characters you want to match, and you can use wildcards inside them to specify entire categories of characters. For example, [%d] is exactly the same as [0123456789].
_________________
EDIT: I didn't like my old signature
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Fri Aug 15, 2014 12:47 pm   
 
Code:
^You still have to kill ~* (*) ~((*)~)$

Code:
You still have to kill * a Dragon Gladiator (Cell B1B (Upper))


%1 = a Dragon Gladiator (Cell block B
%2 = Upper Back)

I am not sure how to use regex so it catch the extra parentheses and still working without the extra parentheses ?
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Fri Aug 15, 2014 10:29 pm   
 
Do not use regex. Use what MattLofton suggested.
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Sat Aug 16, 2014 7:22 am   
 
Sorry I don't get it

How do I tell my trigger to use range to capture text and ()

[a-zA-Z()] this breaks my trigger
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Sat Aug 16, 2014 7:47 pm   
 
You probably forgot to include a space, right?

But to finally solve your problem: You want the first capturing group NOT to enter into parentheses. You can do this with any of these range patterns [a-z ], [a-z1-9 ], [%a ]. Pick whichever suits you best.
By default upper/lower case does not matter, so [a-zA-Z] is redundant.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Aug 18, 2014 12:08 am   
 
No, actually, he does want to include the parentheses as they can sometimes appear between the outermost pair. Parentheses ARE a special character, though, so you have to quote them.
_________________
EDIT: I didn't like my old signature
Reply with quote
rozdwojeniejazni
Wanderer


Joined: 13 Aug 2011
Posts: 74

PostPosted: Mon Aug 18, 2014 6:12 am   
 
Yeah, that's why i wrote about the first capturing group. The second would stay a star like this:
Code:
^You still have to kill ~* ([%a ]) ~((*)~)$
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Mon Aug 18, 2014 6:35 pm   
 
Thanks rozdwojeniejazni

Its so simple when I see it :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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