Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tq8g5-0002KA-9j for pgsql-general@arkaria.postgresql.org; Thu, 06 Mar 2025 10:42:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tq8g3-006i3C-Rt for pgsql-general@arkaria.postgresql.org; Thu, 06 Mar 2025 10:42:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tq8g3-006i34-HT for pgsql-general@lists.postgresql.org; Thu, 06 Mar 2025 10:42:07 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tq8g0-001HQg-0s for pgsql-general@postgresql.org; Thu, 06 Mar 2025 10:42:07 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-2c1c4e364c8so200937fac.1 for ; Thu, 06 Mar 2025 02:42:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741257723; x=1741862523; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Sw+JFJ9dBbt8znf0Tql2pWTKrh3HqVYH+Yd4KQEJcdk=; b=Kb/KznQwWgsRwvEnXf0lclrOa1MYrGvXUuYIBecdiuFF7KAvv7zAg7b+zFcn+q1g9j rPmvq3T2TJ1osNhPAzOtIQLumVhacx5zK2CqIFPgbYqZmvQMDwi8jddqTqN2ZVGOmTgp O4WLTRfgBDYRfeHSPXz5w5q/z2c+kUS/W3b/zVxI8pDCz0NKmN0TkmNlTDiE9e5okUJB G7Qx6QXON8ofkrHd1ynrrXifi3mOQoZWCVuJbAqUbMZx26pLfzH+ft9xmnREjx3xbMB9 LeUkz0h49oChu7k45wa3dT/hUtkglGrVVqVbtcxPxkDBEvXcTMIeI0BEW7gn8PHK5lqT Ajhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741257723; x=1741862523; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sw+JFJ9dBbt8znf0Tql2pWTKrh3HqVYH+Yd4KQEJcdk=; b=pRsAgvbhtoOFK4v6TKLkWCLgdH/nBARUq5nFcZ7RdFbBVKPt58mnT/JLhT9BGxGkKU n8vJWqk3lMnK2Dln+eCH+Ify1kvIIa7ipaUbzhjiFKzQ6ye8J1JqLOVU3Hsy5CnYa/eF dod2KNbFEmeBaKaTQSWdvpK8dYlBtNrMdozucvIOCA6Xa1mnEZh5Lk+K6mnAING/LswU 5smFU+/n9HTPtZN9LIcd6NsR79QsfA7Ss358MZ30loxEsxy666t9kMYR6qvmzn4xjC1w VE5UZ5UoPOHy8XCTr4eh0HeZR7LpOmUkFGxTvYrRYyhChO77yvrvsDLBuD+vCntF9wC7 oR8w== X-Gm-Message-State: AOJu0Yw97PnbhzscfhFSXyRDPf9tnBarByLKgOmN9P6SkxLwuRMQEsja FqMIRrvNGr36/O7OxJ3AQAjGSvJ7nMrdlxRHsqz6DA/WpSbuew9PO2PHHUsuEwAlCHn0Y4+Rufe GrFZ9PjWgThgHKCgrU5UJ3MEMbz4= X-Gm-Gg: ASbGncuIo+mDKAH76bdGznnTbAq9oOrSDxO0w9L6qHAPchkik+7p8jDpAVU02lR2KGF jGwFlUIqlfASyDVvN/4VJmKBPYIf+M7Japft7c1XbljGsUBxKPzrmVujqzj8oaQ+ieAH4cMIVVY MmmQAlTsH6L/SCBJRBq/cHsLVDkRpY X-Google-Smtp-Source: AGHT+IH/+ou4IzDyLp/d2NmC7cELAEnmeCmcGM9h0YEXEf4vW+3omC3NMDlxiwt7WDv4pPixg3C+gqbBI33jCbFdJRY= X-Received: by 2002:a05:6870:494b:b0:2c1:539a:6071 with SMTP id 586e51a60fabf-2c23e9ce476mr1547284fac.10.1741257723072; Thu, 06 Mar 2025 02:42:03 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Dominique Devienne Date: Thu, 6 Mar 2025 11:41:42 +0100 X-Gm-Features: AQ5f1JoEo1KZNksJdZ4fKlNP4K41-34W8xGqvY6-ggyAl4nRVpOgPRDbPvTA-Bo Message-ID: Subject: Re: psql and regex not like To: Ron Johnson Cc: pgsql-general Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 6, 2025 at 11:24=E2=80=AFAM Ron Johnson wrote: > I already do that. This is part of a long chain of commands so I'm tryin= g 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 n= eed 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=3Dacme" -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