Regular Expression Trigger

Posted by Artel on Sat 25 Mar 2006 11:53 PM — 2 posts, 13,513 views.

USA #0
I've tried to make a trigger to try to capture only names from output such as:
     - (C) Zombie
     - (I)(T)(G)(W) a young thief
     - (R)(W) Fnor
     - Tom

However, the problem is that there may be any number of (C), (I), (G), such things before the names. I've managed to capture the names such as Zombie, a young thief, and Fnor; however, I cannot find a way to capture the name Tom.

The following regexp trigger will capture Zombie, a young thief, and Fnor:
^     \- \((.+)\) (.*?)$

Now I thought I could modify it like this to capture Tom:
^     \- (|\((.+)\) )(.*?)$

It does capture Tom, but now it also captures the parentheses all in the same wildcard.

Would anyone know how I could make a trigger to only capture the names from that list?
Amended on Sat 25 Mar 2006 11:54 PM by Artel
Australia Forum Administrator #1
It would help to put in a sequence for the name that is what you are expecting rather than the "." symbol because that matches everything, including brackets. This one worked for me in all cases:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^     \- (\([A-Z()]+\) )?([\w\s]+)"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>


This sequence here matches what is inside the brackets:


(\([A-Z()]+\) )?


It looks for the opening bracket, and then A-Z or other brackets, and then the closing bracket - and the space after it. The final ? means "0 or 1 of them" which allows for the case of Tom who has no brackets at all.