🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #285055

Re: Regex help

#285055
From: elvis-85514
Date: Sat, 01 Oct 2016 12:00
23 lines
1890 bytes
On 2016-09-30, Fritz Wuehler <fritz@spamexpire-201609.rodent.frell.theremailer.net> wrote:
> nobody@dizum.com (Nomen Nescio) wrote:
>> > /^From:([^<]*)<[^>]*> (<.*>)$/From:$1 $2/
>> From: My Name <something> <myname@foo.bar> => From: My Name <myname@foo.bar>
>
> I'm not very much in to RegEx... is there an advantage for
> "[^>]*>"
> instead of
> ".*?>"

If the aim is to capture 2 strings and reject the distraction
putting focus on the intended content rather than the distraction
may be more robust.
 /^From:([^<]*).* (<[^<>]*>)$/From:$1 $2/
That passes 3 test cases rather than 1.

use Test::Simple tests => 3;
use apas_email_re;
ok(apas_email_re::zap('From: My Name <something> <myname@foo.bar>') eq 'From: My Name  <myname@foo.bar>');
ok(apas_email_re::zap('From: My Name <some<>thing> <myname@foo.bar>') eq 'From: My Name  <myname@foo.bar>');
ok(apas_email_re::zap('From: My Name <some><thing> <myname@foo.bar>') eq 'From: My Name  <myname@foo.bar>');

Both expressions produce a double space (different from the spec with => above).
Technical Details
Message-ID: <slrnnuv9b1.ial.elvis-85514@notatla.org.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
References: <nru6o8$vjr$2@dont-email.me> <359ac464de7211bd502cb13fd0a22d24@dizum.com> <ea9f00590b8773eb129789e536b19fa1@msgid.frell.theremailer.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrnnuv9b1.ial.elvis-85514@notatla.org.uk>
Subject: Re: Regex help
Date: Sat, 01 Oct 2016 12:00:33 GMT
From: elvis-85514@notatla.org.uk
References: <nru6o8$vjr$2@dont-email.me> <359ac464de7211bd502cb13fd0a22d24@dizum.com> <ea9f00590b8773eb129789e536b19fa1@msgid.frell.theremailer.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
Newsgroups: alt.privacy.anon-server
X-noarchive: yes
X-no-archive: yes
User-Agent: slrn/1.0.1 (Linux)
Lines: 23
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Sat, 01 Oct 2016 12:00:33 UTC
Organization: blocknews - www.blocknews.net
X-Received-Bytes: 1707
X-Received-Body-CRC: 652096682