|
Quit Wanderer
Joined: 19 Jul 2008 Posts: 59
|
Posted: 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 ? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Quit Wanderer
Joined: 19 Jul 2008 Posts: 59
|
Posted: 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 ? |
|
|
|
rozdwojeniejazni Wanderer
Joined: 13 Aug 2011 Posts: 74
|
Posted: Fri Aug 15, 2014 10:29 pm |
Do not use regex. Use what MattLofton suggested.
|
|
|
|
Quit Wanderer
Joined: 19 Jul 2008 Posts: 59
|
Posted: 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 |
|
|
|
rozdwojeniejazni Wanderer
Joined: 13 Aug 2011 Posts: 74
|
Posted: 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. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
rozdwojeniejazni Wanderer
Joined: 13 Aug 2011 Posts: 74
|
Posted: 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 ]) ~((*)~)$ |
|
|
|
|
Quit Wanderer
Joined: 19 Jul 2008 Posts: 59
|
Posted: Mon Aug 18, 2014 6:35 pm |
Thanks rozdwojeniejazni
Its so simple when I see it :) |
|
|
|
|
|