Re: psql and regex not like

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql and regex not like
Date: 2025-03-06 10:41:42
Message-ID: CAFCRh-8TmYG4Ya_VLsRy2ybZSfYfuOzZ_i0+EGxSkrbja1JZWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Mar 6, 2025 at 11:24 AM Ron Johnson <ronljohnsonjr(at)gmail(dot)com> wrote:
> I already do that. This is part of a long chain of commands so I'm trying to minimize the length of commands.

but given that your regexp patterns are not anchored, they are not
equivalent. I think mine is "more correct".

> Anyway, it would be good to know the answer for any future queries that need multiple exclusions.

Sure. First, it works fine with TCSH :). I repro a (different) failure
in BASH. But the below works fine for me:

psql "service=acme" -Xc 'select datname from pg_database where datname
!~ $$(template|postgres)$$ order by 1'

i.e. use single-quotes, and an inner $$ literal. One of 3 options an
AI chatbot gave me. --DD

In response to

Browse pgsql-general by date

  From Date Subject
Next Message François Lafont 2025-03-06 10:45:49 Re: psql and regex not like
Previous Message Ron Johnson 2025-03-06 10:24:29 Re: psql and regex not like