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
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sun Jan 01, 2006 10:52 pm   

Regex multi-line capture, too many lines?
 
OK, so first off, I've gone through as many of the old posts about multi-line capture as I could handle without killing something and I haven't found anything like this (I could be wrong, but I tried).

I'm working on a trigger to capture multi-line output from channels, do a few minor formatting details, and send it to another window.

Here's my class.

Code:
#CLASS {capture}
#VAR channels {DasaisonskyblueOrderdodgerblueCongregationcornflowerblueRingdarkseagreen}
#REGEX {^\((.+?)\): (You|[A-Z][a-z]+) says?, ~"((?:.+?\n?)+?(?:.|\?|\)|!))~"$\n} {#win capture %concat( "<color ", @{channels.%subregex( %1, "'", "")}, ">", %1, ": ", %2, ": ", "%3", "</color>")} "" {nocr|prompt|notrig}
#CLASS 0

(Note: The var channels is just a db var which has as keys the names of various channels and as values the colours I want each coloured, that part works perfectly even though the board isn't correctly showing the special characters.)


Here's some sample output from the mud:

Quote:

(Da'saison): Araedelith says, "Righto. Once upon a time there was still a
fluffy pink bunny named Lyrith that started a bloodline called the Da'Saisons.
They still follow Lord Janus, but they're having issues with line wraps."
<299/299h 374/388m 1398e 1840w <eb> <94>> ft Thanks.
(Da'saison): You say, "Thanks."
<299/299h 374/388m 1398e 1840w <eb> <94>> ft Damn line wraps.
(Da'saison): You say, "Damn line wraps."

(Note: The channel line can end in any sort of punctuation, as you can see from the regex.)

Here's the problem.

It catches perfectly any one or two line channels, such as the last two lines that I said...but fails to capture anything with 3 or more lines. (And some debugging echos show that it's not even matching on > 3 lines.) I've tried copy-pasting that pattern into The Regex Coach but it works fine for really really long examples there, so I'm really not sure what's going wrong...

And here's the catch...

It needs to be just one line of pure regular expression, no ZMud magic, no multi state triggers, etc. (Otherwise it'd have been done long ago, since there's about a billion better ways.)

Bonus points: At some point it strips the new lines, but I would rather do it manually so that I can check for spaces at the end (if a line is exactly 80 characters long plus a space at the end, the space gets dropped) and fix them if necessary. How to force it to not strip new lines?
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