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
herbster69
Newbie


Joined: 20 Nov 2009
Posts: 8

PostPosted: Fri Nov 20, 2009 4:09 pm   

Regular expression
 
I'm having a problem with writing a regular expression for a prompt trigger I want to use.

Example of the text requiring triggering are

1234h, 2345m ae-
1234h. 2345m -

The following trigger matches the 1st 2 variables (1235 & 2345):

^([0-9]+)h, ([0-9]+)m

The problem I have is the character(s) or not, preceding the "-". ^([0-9]+)h, ([0-9]+)m ([A-z]+)- will capture the characters but only if any exist.

I would like to a trigger to match even if there is nothing preceding the -.

Once I get a value for the 3rd variable (it can include the - btw) I can then search within the variable for characters to determine what.

Thanks
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Nov 20, 2009 4:17 pm   
 
Code:
#REGEX {^([0-9]+h, ([0-9]+)m ([A-z]+)?-} {Do whatever here. It will match %3 if it's there, and not bother the trigger if it's not there.}


Charneus
Reply with quote
herbster69
Newbie


Joined: 20 Nov 2009
Posts: 8

PostPosted: Fri Nov 20, 2009 4:20 pm   
 
excellent, thanks.
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