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


Joined: 30 Oct 2004
Posts: 127

PostPosted: Wed Jul 20, 2005 4:00 am   

#Regex....Multiline Triggers.....how do they work?
 
Basically what I am trying to do is take this text :

*****************************
Though too far away for you to accurately perceive details, Whoever is in
Whereever.
*****************************
The asterix's aren't in the Mudd text, just seperating it

And I want to be able to store the 'whereever' in a variable to I can get at it with another alias. Now, since it's multiline, I found some #Regex stuff, but I can't make heads or tails of it, and need some help if anyone could lend a hand.

So in total, what I'd like is that it stores 'whereever' in a variable and 'whoever' as well if possible.

Thanks ahead of time.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Jul 20, 2005 11:17 am   
 
Code:
#REGEX {^Though too far away for you to accurately perceive details, (?person:.+) is in\n(?location:.+)\.$}


The ^ forces the match to begin at the start of a line
\n tells the match that it's a new line
using (?:variable:.+) assigns the captured text straight to a variable.
$ forces the match to end at the end of a line

So the one above will match
Though too far away for you to accurately perceive details, whoever is in
wherever.

assigning 'whoever' to a variable called person, and 'wherever' to a variable called location.

Hope that's what you're after.

A good way to get used to using Regex is to make the triggers normally, then use convert and get used to which bits change.

Guinn
Reply with quote
luggage
Novice


Joined: 20 Jul 2004
Posts: 38
Location: Australia

PostPosted: Thu Jul 21, 2005 11:05 am   
 
Hrm a decent page that I found that explains the basics of REGEX very simply is

http://www.regular-expressions.info

It is way easier to understand than the web site given in the Zmud help files.

Luggage
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