Article View: news.software.readers
Article #166535Re: [slrn] Macro to delete block of text
From: John E. Davis
Date: Tue, 10 May 2005 06:10
Date: Tue, 10 May 2005 06:10
27 lines
1695 bytes
1695 bytes
On 10 May 2005 14:13:27 +0950, Ian Petts <ipetts@gmail.com_no_spam_thanks>
wrote:
>I'm now trying to work out how to count the number of lines in the
>string, so I can delete from X to the end of the text.
If by the number of lines, you mean the number of \n characters, you
can use:
#v+
lines = strchop (string, '\n', 0);
num_lines = length (lines);
#v-
Then if you want just the first n lines, use:
#v+
lines = lines[[0:n-1]];
#v-
Finally, to convert it back from an array of strings to a single
string, use strjoin:
#v+
string = strjoin (lines, "\n");
#v-
--John
Technical Details
Message-ID:
<slrnd80k34.usb.davis@aluche.mit.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!newspump.monmouth.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mailReferences:
<slrnd7vtch.bai.ipetts@lexx.pettsie.net> <slrnd804b3.2cg.wcitoan@wcitoan-via.supernews.com> <slrnd80eve.bc1.ipetts@lexx.pettsie.net>Show Full Headers
Complete Article Headers
Message-ID: <slrnd80k34.usb.davis@aluche.mit.edu> Subject: Re: [slrn] Macro to delete block of text Date: Tue, 10 May 2005 06:10:45 +0000 From: davis@space.mit.edu (John E. Davis) References: <slrnd7vtch.bai.ipetts@lexx.pettsie.net> <slrnd804b3.2cg.wcitoan@wcitoan-via.supernews.com> <slrnd80eve.bc1.ipetts@lexx.pettsie.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!newspump.monmouth.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail Newsgroups: news.software.readers Organization: Center for Space Research Reply-To: davis@space.mit.edu Fcc: =sent.gz User-Agent: slrn/0.9.6.4 (Linux) Lines: 27 NNTP-Posting-Host: ALUCHE.MIT.EDU X-Trace: 1115705445 senator-bedfellow.mit.edu 574 18.75.2.45