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


Joined: 28 Dec 2006
Posts: 12

PostPosted: Tue Jan 22, 2008 2:34 pm   

trig matching multiple times per line
 
got something like this:

A sharp-toothed gremlin#209277, a chaos orb#233372.

can be more than two or just one entry. What I'm trying to do is grab the <name>#<number> in a db variable
Got this pattern:
Code:
(%x)#(%d)%p


problem is it only matches once per line.. only grabbing the first occurance.. How can I make it grab all of them?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jan 22, 2008 6:02 pm   
 
Use a regex:

^(?:[^\#]+\#\d+[,\.]\s*)+$

Should match the line no matter how many examples are on it. You'll need to do some post-processing with the %replace function to get the names and numbers out (I did experiment with bracket-capturing in the regex but couldn't find a way that worked consistently), but that'll match the line properly.
_________________
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