Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
dratcha
Newbie


Joined: 26 Sep 2002
Posts: 8

PostPosted: Sun Sep 29, 2002 12:08 am   

Pattern matching for a sentance.
 
I am trying to only get the first sentance in a room description for a trigger.
If I use:
^*.
It grabs the whole paragraph. I'm not sure how to use %w since I don't know how many words may be in the sentance.
How can I do my expression so it only grabs the first sentance which stops on the first period?
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sun Sep 29, 2002 1:54 am   
 
If you only have letters and spaces in the sentences and they all end with periods, a pattern of ^([a-z].) should work. If, however, your sentences sometimes have punctuation in them or end in things other than periods (like exclamation points or question marks), you'll need something more robust like:

^([a-z ()~~`@#$%^&*-_+={}[~]|:;"'<>,/]{.|?|!})

Both of these methods result in the first sentence being in %1 where you can do whatever you want with it.

Another solution is to pull in the first line regardless and then use %pos and %left to get only the part up to the first period. Like:

#TRIGGER {^(*)$} {#VAR FirstSentence %left("%1", %pos("%1", "."))}

For more information on pattern matching, go here.

 - Charbal
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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