From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11510 invoked from network); 30 May 2022 08:01:35 -0000 Received: from minnie.tuhs.org (2600:3c01:e000:146::1) by inbox.vuxu.org with ESMTPUTF8; 30 May 2022 08:01:35 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 5A05E421F0; Mon, 30 May 2022 18:01:33 +1000 (AEST) Received: from relay05.pair.com (relay05.pair.com [216.92.24.67]) by minnie.tuhs.org (Postfix) with ESMTPS id 6308740CC0 for ; Mon, 30 May 2022 18:01:31 +1000 (AEST) Received: from orac.inputplus.co.uk (unknown [84.51.159.244]) by relay05.pair.com (Postfix) with ESMTP id 9D1B51A28E8 for ; Mon, 30 May 2022 04:01:30 -0400 (EDT) Received: from orac.inputplus.co.uk (orac.inputplus.co.uk [IPv6:::1]) by orac.inputplus.co.uk (Postfix) with ESMTP id BDA1521F8A for ; Mon, 30 May 2022 09:01:29 +0100 (BST) To: coff@tuhs.org From: Ralph Corderoy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit In-reply-to: <0a704531-b12d-42ff-b82c-5af5d935bf1a@home.arpa> References: <0a704531-b12d-42ff-b82c-5af5d935bf1a@home.arpa> Date: Mon, 30 May 2022 09:01:29 +0100 Message-Id: <20220530080129.BDA1521F8A@orac.inputplus.co.uk> Message-ID-Hash: HQPM3PKPUVIRPJJX2AQ4DQ5JT5DQLOJV X-Message-ID-Hash: HQPM3PKPUVIRPJJX2AQ4DQ5JT5DQLOJV X-MailFrom: ralph@inputplus.co.uk X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [COFF] Re: Grep has gone overboard List-Id: Computer Old Farts Forum Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Hi Michael, > I was trying to do something very similar using procmail regexes some > time ago, only with strings instead of individual characters (for > parsing and matching on arbitrarily-ordered, comma-separated values > within a header). I never did come up with a good solution. Assuming procmail has BRE, this does one interpretation of what you said. $ grep '^ *field *: *\(foo\|bar\|xyzzy\)\( *, *\(foo\|bar\|xyzzy\)\)* *$' <<\E > otherfield: foo > field: > field: , > field:foo > field : foo > field:xyzzy > field: xyzzy,bar, foo , xyzzy > field: xyzzy,bar, foo , xyzzy , > E field:foo field : foo field:xyzzy field: xyzzy,bar, foo , xyzzy $ If I was doing it in sed, I'd s/$/,/ before and s/,$// after so the list of alternatives need only be given once with each alternative having to be followed by a comma, i.e. the comma switches from separator to terminator. -- Cheers, Ralph.