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
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Thu Jun 11, 2009 10:16 pm   

Splitting the trigger pattern abnormally
 
So here is the best way I can think of to explain what I want to do.

"This is an example paragraph. I want it split and saved into two variables. Lets call the first variable Var1 and the second variable Var2."

So for the pattern lets say I had something like

Code:
^(&Var1). (&Var2)


The way it would save it is by splitting at the last period found. So every sentence except the last one would be placed into Var1.
I want to do the opposite. I want Var1 to only have the first sentence, and Var2 to have the rest of the paragraph. Any way to do this?
The paragraphs will always be different and could contain any number of sentences (my example assumes they'll always end in a period)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Jun 11, 2009 11:15 pm   
 
Use a regex. Regexes can do anything :P See also.

Anyway, you want something like

^(.+)\. (.+)\.$"

Because the first + is greedy, it should capture everything except the last sentence.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Fri Jun 12, 2009 10:16 am   
 
So how would that translate into this

^~(chatname~) Person wisps: Q%d. &Var1. &Var2

Thanks in advance. Apparently I don't know much about regex. I'll do some reading.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Jun 12, 2009 1:56 pm   
 
This should do what you want.
Code:
^\(chatname\) Person wisps: Q\d+\. (?Var1:.+)\. (?Var2:.+)\.$


The easiest way to is to click the Convert butter when you edit your trigger. It will automatically translate a zMud trigger pattern to a a regex.
_________________
Asati di tempari!
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