|
Fizban1216 Apprentice
Joined: 03 Feb 2007 Posts: 170
|
Posted: Fri Mar 06, 2009 3:34 pm
Stupid Regex question |
Hoe exactly does the regex syntax work for triggers? I know it says it uses %/regex/% but I'm guessing I'm misinterpreting exactly where the pattern itself goes as while the following trigger looks simple I can't seem to get it to work.
An example is trying to match the following text.
Directions: [north south west east]
A small bug is flying here.
I tried:
#TRIG {~]%//n/%A small bug is flying here.} {c 'lightning bolt' bug}
as well as:
#TRIG {~]%regex(\n)A small bug is flying here.} {c 'lighting bolt' bug} |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Mar 06, 2009 3:49 pm |
If you want your entire pattern to be a regex, just check the regex option for the trigger - you might find that easier. The syntax, anyway, is %/regex/%, so you want %/\n/%. Your first example was using %/regex/% correctly but had an incorrect regex.
|
|
|
|
Fizban1216 Apprentice
Joined: 03 Feb 2007 Posts: 170
|
Posted: Fri Mar 06, 2009 4:25 pm |
Thanks, that part works, on a similar note, any reason none of the following work?
#TRIG {~]%/\n\n/%~<} {scan}
#TRIG {~]%/\n/%%/\n/%~<} {scan}
#TRIG {~]%/\n/%%s} {scan}
Trying to make it match the following text:
The < doesn't really need to be checked for, it's more so the ] followed by a line starting with whitespace that is important hence the third attempt. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Mar 06, 2009 5:07 pm |
It'd be simpler, I think, just to use a multistate trigger:
#trig {^]} {blah1}
#cond {^%s} {blah2} {within|param=1}
job done. |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Mar 06, 2009 8:47 pm |
Remember you can also use #regex to create a (completely) regex trigger off of the command line. This is the same as creating a trigger and manually ticking the regex box.
|
|
|
|
|
|