Article View: news.software.readers
Article #166518Re: [slrn] Macro to delete block of text
From: W. Citoan
Date: Tue, 10 May 2005 01:41
Date: Tue, 10 May 2005 01:41
38 lines
2113 bytes
2113 bytes
Ian Petts wrote:
>
> I want to be able to delete from, say, '---' to the end of the
> article, but have had little success. In particular, I can't seem to
> match from my expression to the end of the text. Here is the code I
> have been using as a test:
>
> variable div = "---";
> variable article="line 1\nline 2\nline 3\n---\nafter1\nafter2\nafter3+end";
>
> if (string_match(article, div, 1)) {
> (article,) = strreplace(article, div, "", strlen(article));
> printf("%s\n", article);
> }
>
> This removes the divider just fine, but how can I include the rest of
> the text? Adding a "\n.*" RE to the search string doesn't help.
strreplace is the wrong function in this case. It does not use regex so
you cannot give it a pattern. Instead, you can use substr is pull out
the part that you want to keep.
variable div = "---";
variable article="line 1\nline 2\nline 3\n---\nafter1\nafter2\nafter3+end";
variable start;
if ( string_match(article, div, 1) ) {
(start, ) = string_match_nth(0);
article = substr(article, 1, start);
}
printf("%s\n", article);
- W. Citoan
--
If voting changed anything, they'd make it illegal.
-- Graffiti
Technical Details
Message-ID:
<slrnd804b3.2cg.wcitoan@wcitoan-via.supernews.com>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.ams.giganews.com!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!sn-xit-02!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mailReferences:
<slrnd7vtch.bai.ipetts@lexx.pettsie.net>Show Full Headers
Complete Article Headers
Message-ID: <slrnd804b3.2cg.wcitoan@wcitoan-via.supernews.com> Subject: Re: [slrn] Macro to delete block of text Date: Tue, 10 May 2005 01:41:56 -0000 From: "W. Citoan" <wcitoan@NOSPAM-yahoo.com> References: <slrnd7vtch.bai.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.ams.giganews.com!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!sn-xit-02!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Newsgroups: news.software.readers Organization: Posted via Supernews, http://www.supernews.com User-Agent: slrn/0.9.7.4 (Win32) X-Complaints-To: abuse@supernews.com Lines: 38