Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFfRg-0004Qt-Px for pgsql-sql@arkaria.postgresql.org; Thu, 03 Feb 2022 16:58:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nFfRe-0006cE-R5 for pgsql-sql@arkaria.postgresql.org; Thu, 03 Feb 2022 16:58:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFfRe-0006c5-Df for pgsql-sql@lists.postgresql.org; Thu, 03 Feb 2022 16:58:54 +0000 Received: from smtp116.ord1d.emailsrvr.com ([184.106.54.116]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFfRb-0007NN-SP for pgsql-sql@lists.postgresql.org; Thu, 03 Feb 2022 16:58:53 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp7.relay.ord1d.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 68DF520175; Thu, 3 Feb 2022 11:58:50 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: How best to work around the issue - regex string cannot contain brackets From: Christophe Pettus In-Reply-To: Date: Thu, 3 Feb 2022 08:58:45 -0800 Cc: pgsql-sql X-Mailbutler-Message-Id: 1A75D133-BABC-4189-8504-05B9FD4FB1C0 Content-Transfer-Encoding: quoted-printable Message-Id: <7AF5777D-148E-4534-B442-891A911B0D2B@thebuild.com> References: To: Shaozhong SHI X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Classification-ID: b2dc339d-66e3-42fa-ba8a-fa48855e5cdb-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Feb 3, 2022, at 08:53, Shaozhong SHI = wrote: >=20 > One would consider the following would work, but it did not because = the brackets. > select regexp_matches('Department for Transport (Parking)', = 'Department for Transport (Parking)', 'g') >=20 > Can anyone enlighten me? You escape the ()s with a backslash: xof=3D# select regexp_matches('Department for Transport (Parking)', = 'Department for Transport \(Parking\)', 'g'); regexp_matches =20 ---------------------------------------- {"Department for Transport (Parking)"} (1 row)