🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #119652

Re: [slrn] Importing pgp keys

#119652
From: John E. Davis
Date: Sun, 02 Feb 2003 20:31
35 lines
2340 bytes
On Sun, 02 Feb 2003 12:31:13 GMT, Emmanuele Bassi <zefram@wolverine.lohacker.home>
wrote:
>If it was Perl, yes: it would be possible... String matching it's not
>S-Lang's strong point. ;-)

For what it is worth, I have an experimental pcre module that I can
make available.  The module provides 3 functions:
#v+
   PCRE_Type pcre_compile (pattern);
   Int_Type pcre_exec (PCRE_Type p, String_Type s, Int_Type offset);
   Int_Type[2] pcre_nth_match (PCRE_Type p, Int_Type n);
#v-
I do not yet have support for the various options supported by the
PCRE library, e.g., character table support.

Here is a simple example of how it can be applied to a string:
#v+
   import ("pcre");
   define pcre_str_match (str, pattern)
   {
      variable p = pcre_compile (pattern);
      if (0 == pcre_exec (p, str))
        return NULL;  % match failed
      variable i = pcre_nth_match (p, 0);
      return substr (str, i[0]+1, i[1]-i[0]);
   }
#v-
So, if str matches the pattern, the matched text will be returned.  If
not, the function will return NULL.  The pcre_nth_match function can
be used to find other so-called "captured substrings".
-- 
John E. Davis                   Center for Space Research/AXAF Science Center
617-258-8119                    One Hampshire St., Building NE80-6019
http://space.mit.edu/~davis     Cambridge, MA  02139-4307
Technical Details
Message-ID: <slrnb3r01j.tdc.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.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail
References: <slrnb3nfim.88m.bilbono@bilbo.balings> <slrnb3okmo.33s.zefram@wolverine.lohacker.net> <slrnb3pooo.mm.bilbono@bilbo.balings> <slrnb3q3ga.4ij.zefram@wolverine.lohacker.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrnb3r01j.tdc.davis@aluche.mit.edu>
Subject: Re: [slrn] Importing pgp keys
Date: Sun, 02 Feb 2003 20:31:47 +0000
From: davis@space.mit.edu (John E. Davis)
References: <slrnb3nfim.88m.bilbono@bilbo.balings> <slrnb3okmo.33s.zefram@wolverine.lohacker.net> <slrnb3pooo.mm.bilbono@bilbo.balings> <slrnb3q3ga.4ij.zefram@wolverine.lohacker.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.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.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
User-Agent: slrn/0.9.6.4 (Linux)
Lines: 34
NNTP-Posting-Host: ALUCHE.MIT.EDU
X-Trace: 1044217907 senator-bedfellow.mit.edu 3936 18.75.2.45