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


Joined: 25 Jan 2008
Posts: 7

PostPosted: Wed Jan 30, 2008 11:35 pm   

Pattern Matching/Exclusion
 
Ok, so I have a trick pattern matching here. I want to take a pattern, extract only letters and do something with it. Example:

The WND Juggernaut ¿B?L¿O?O¿D?Y¿K?E¿E?L¿

I want it to take ¿B?L¿O?O¿D?Y¿K?E¿E?L¿ part and extract only the letters...so I was thinking something like:

Code:
#TRIGGER {^The ??? {juggernaut|blah|blah} ([a-z, ' '])} {#var shipname %1}}


The WND part can change as well as the juggernaut, but thats not the issue. Yet that doesn't work. Is some sort of nasty regex needed or is there a way to ignore characters other than letters in a pattern and store it to a variable?

I don't know perl but someone said use something along the lines of

Code:
$shipname =~ s/[\*\+=\(\)\&\^\%\$\#\@\!\[\]\{\}+]//g;


but I wouldn't know what to do with that at all.

Any ideas?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jan 30, 2008 11:49 pm   
 
Eh, there's not an easy way to get the characters out with a pattern, but you can do it easily with the %subchar function or the %replace function once you've matched it. So:

#trig {^The ??? {whatever|Juggernaut} (.+)} {#var shipname %subchar(%1, "?")}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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