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
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Thu Mar 09, 2006 12:28 am   

Perl chomp equivalent?
 
In Perl you can do a chomp which will remove the last character of a line if and only if it is a newline character. When I capture channel text to a separate window, the window width is different so I'd like to remove the newline characters to keep it from fragmenting the lines mid-sentence in the other window.

Perhaps I can do a subregex, but would I search for "\n"?
Reply with quote
Tech
GURU


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

PostPosted: Thu Mar 09, 2006 3:26 am   
 
Yes... you can and you would search for '\n'.

Your expression would be something like

Code:
#TRIGGER { (*) } { #VAR NewString %subregex("%1","(*)\n","%1")}


Alternatively you could try (which may be more efficient)

Code:
#TRIGGER { (*) } { #IF (%ends("%1", "\n")) { #VAR NewString %leftback("%1",1)}   }
_________________
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