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=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,MIME_QP_LONG_LINE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3080 invoked from network); 30 May 2022 06:51:22 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 30 May 2022 06:51:22 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id B563F40C3C; Mon, 30 May 2022 16:51:20 +1000 (AEST) Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by minnie.tuhs.org (Postfix) with ESMTPS id 6F9D740C2F for ; Mon, 30 May 2022 16:51:16 +1000 (AEST) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-f2cd424b9cso13192399fac.7 for ; Sun, 29 May 2022 23:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=Dy/ALmf5xnAn/L+Crdx1vvJiS4p3ruzDsf/e4RSwvbc=; b=xkCu3CvlDuC/OGRhRIx13fB6Rl7fORh8aH207sfa8i1nMjC/tYBmmCA6A1atX3mKb9 y/qq2oiUFbmlC3PSspryKAXUaHV5mybNuKoi+l335BxzPsbtoXBN5FxZsnuK4j52VZDE 4Y4zzsVOmV/7PaWRY6QZ+6KVd9OPK0maftBCZNP2s5ES3QyZ1AZvSOJmx7fj6g1lVbKD kFapu1b3dh8k6b+UXA1EeSSrnml+xdspvJwzVsPkhvl4YvGHnAmGg6juXUGC3mntUiU0 SqLTnbCIYadPypIXQ2B5wVMiQMLulG3NHOj8bxqeZgO/+umv6HC/TfvHNy3BZWsh+7TT gdgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=Dy/ALmf5xnAn/L+Crdx1vvJiS4p3ruzDsf/e4RSwvbc=; b=G7+Fc9kqysGN3rTvMfeerWvOnMDgZ6SkTnnpoj82nBv5NSvdtAEhxIcCyn2GqAW6SF xcsV6HwTeHkKOCYnsPAIbf82Df2osMJLlyLDC2NjehkoBtdwT+Trx/hMbxhtQGUAQ58T SViUgstpW+1BBBkfddbvgIWcXBGrWCMjooakpRb2UDtf//psSVBWBdzeMIGn1Fkj7nbR wEcqDQ1omL5+ge1kOWcy5e3Yq40cRCfTjVNxauCaJuqpBB+YazpxzUhQtgts5p0mmWBw Xd/78tcYfxTmcPRCbgmjxUrQZ8gBQlSfp1vdNBLd2smS4sin4zL0g7/3SqEMu6kMB5BR I00A== X-Gm-Message-State: AOAM533LmeF/RjMW3lNt1GHwDaCK5MpIS0qvqsJrgdoEW1D/6GCsviwq yggCEh+RaqWFT7/UA4ueo3dBtEJ/En2j/oGk X-Google-Smtp-Source: ABdhPJzHMiDk9CT/YEUiH1WFIMNNcQ9dEhUt97dcX7RjgF5mHnRjZKoLZ2ZyVjtxZnHPFrN1VyzY0A== X-Received: by 2002:a05:6870:b39c:b0:d1:4a9f:35f9 with SMTP id w28-20020a056870b39c00b000d14a9f35f9mr8920884oap.119.1653893475402; Sun, 29 May 2022 23:51:15 -0700 (PDT) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id l17-20020a056830269100b0060aeccf6b44sm4796125otu.41.2022.05.29.23.51.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 May 2022 23:51:15 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-0B16355F-E79F-4DBA-8938-7CA0293FAD75 Content-Transfer-Encoding: 7bit From: Bakul Shah Mime-Version: 1.0 (1.0) Date: Sun, 29 May 2022 23:51:14 -0700 Message-Id: <9BBE9119-B5BF-4C4A-B22E-928C37470BA9@iitbombay.org> References: <0a704531-b12d-42ff-b82c-5af5d935bf1a@home.arpa> In-Reply-To: <0a704531-b12d-42ff-b82c-5af5d935bf1a@home.arpa> To: =?utf-8?Q?Michael_Kj=C3=B6rling?= X-Mailer: iPad Mail (19F77) Message-ID-Hash: AB3ZY7LOOPVNMNLSET6S6QZJY2BHIOYS X-Message-ID-Hash: AB3ZY7LOOPVNMNLSET6S6QZJY2BHIOYS X-MailFrom: bakul@iitbombay.org 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 CC: coff@tuhs.org 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: --Apple-Mail-0B16355F-E79F-4DBA-8938-7CA0293FAD75 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Forgot to add, you can solve this another way (taking the abc example): grep =E2=80=98^...$=E2=80=99 | grep =E2=80=98[^a]*a[^a]*=E2=80=99 | grep =E2= =80=98[^b]*b[^b]*=E2=80=99 | grep =E2=80=98[^c]*c[^c]*=E2=80=99 This will scale better for large N and easier to grok and probably what Dave had in mind! > On May 29, 2022, at 11:35 PM, Michael Kj=C3=B6rling w= rote: >=20 > =EF=BB=BFOn 29 May 2022 21:47 -0700, from bakul@iitbombay.org (Bakul Shah)= : >> You can write a program to generate all permutations and use that as your= regexp. >> For example abc maps to abc|acb|bac|bca|cab|cba. You can rearrange it as >> a(bc|cb)|b(ac|ca)|c(ab|ba) to see how an n letter permutation is computed= from >> permutations of n-1 letters. I don=E2=80=99t think you can do better. >=20 > 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. >=20 > --=20 > Michael Kj=C3=B6rling =E2=80=A2 https://michael.kjorling.se =E2=80=A2 mich= ael@kjorling.se > =E2=80=9CRemember when, on the Internet, nobody cared that you were a dog?= =E2=80=9D >=20 --Apple-Mail-0B16355F-E79F-4DBA-8938-7CA0293FAD75 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
For= got to add, you can solve this another way  (taking the abc example):
  grep =E2=80=98^...$=E2=80=99 | grep =E2=80=98[^a= ]*a[^a]*=E2=80=99 | grep =E2=80=98[^b]*b[^b]*=E2=80=99 | grep =E2=80=98[^c]*c[^c]*=E2= =80=99
This will scale better for large N and easier to gro= k and probably what
Dave had in mind!

On May 29, 2022, at 11:35 PM= , Michael Kj=C3=B6rling <michael@kjorling.se> wrote:

=EF=BB=BFOn 29 May= 2022 21:47 -0700, from bakul@iitbombay.org (Bakul Shah):
You can write a program to generate all permutations= and use that as your regexp.
For example abc maps to abc|acb|bac|bca|cab|cba. You can rearrange i= t as
a(bc|cb)|b(ac|ca= )|c(ab|ba) to see how an n letter permutation is computed from
permutations of n-1 letters. I don= =E2=80=99t think you can do better.

= I was trying to do something very similar using procmail regexes some<= /span>
time ago, only with strings instead of individual characters= (for
parsing and matching on arbitrarily-ordered, comma-sep= arated values
within a header). I never did come up with a g= ood solution.

--
Michael K= j=C3=B6rling =E2=80=A2 https://michael.kjorling.se =E2=80=A2 michael@kjorlin= g.se
=E2=80=9CRemember when, on the Internet, nobody cared t= hat you were a dog?=E2=80=9D

<= /body>= --Apple-Mail-0B16355F-E79F-4DBA-8938-7CA0293FAD75--