Computer Old Farts Forum
 help / color / mirror / Atom feed
From: Bakul Shah <bakul@iitbombay.org>
To: "Michael Kjörling" <michael@kjorling.se>
Cc: coff@tuhs.org
Subject: [COFF] Re: Grep has gone overboard
Date: Sun, 29 May 2022 23:51:14 -0700	[thread overview]
Message-ID: <9BBE9119-B5BF-4C4A-B22E-928C37470BA9@iitbombay.org> (raw)
In-Reply-To: <0a704531-b12d-42ff-b82c-5af5d935bf1a@home.arpa>

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

Forgot to add, you can solve this another way  (taking the abc example):
  grep ‘^...$’ | grep ‘[^a]*a[^a]*’ | grep ‘[^b]*b[^b]*’ | grep ‘[^c]*c[^c]*’
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örling <michael@kjorling.se> wrote:
> 
> On 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’t think you can do better.
> 
> 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.
> 
> -- 
> Michael Kjörling • https://michael.kjorling.se • michael@kjorling.se
> “Remember when, on the Internet, nobody cared that you were a dog?”
> 

[-- Attachment #2: Type: text/html, Size: 2163 bytes --]

  reply	other threads:[~2022-05-30  6:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30  4:12 [COFF] " Dave Horsfall
2022-05-30  4:47 ` [COFF] " Bakul Shah
2022-05-30  6:35   ` Michael Kjörling
2022-05-30  6:51     ` Bakul Shah [this message]
2022-05-30  8:26       ` Ralph Corderoy
2022-05-30  8:01     ` Ralph Corderoy
2022-05-30  8:16   ` Ralph Corderoy
2022-05-30  8:43     ` Bakul Shah
2022-05-30  9:19       ` Ralph Corderoy
2022-05-30  7:38 ` Ralph Corderoy
2022-05-30  7:44   ` Ralph Corderoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9BBE9119-B5BF-4C4A-B22E-928C37470BA9@iitbombay.org \
    --to=bakul@iitbombay.org \
    --cc=coff@tuhs.org \
    --cc=michael@kjorling.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).