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
Fizban1216
Apprentice


Joined: 03 Feb 2007
Posts: 170

PostPosted: 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}
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Fizban1216
Apprentice


Joined: 03 Feb 2007
Posts: 170

PostPosted: 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:

Code:

]

<


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.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: 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.
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