Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJOUL-0004nF-Qy for pgsql-sql@arkaria.postgresql.org; Sun, 04 Nov 2018 19:55:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gJOUJ-0000dN-Vi for pgsql-sql@arkaria.postgresql.org; Sun, 04 Nov 2018 19:55:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJOUJ-0000dG-M3 for pgsql-sql@lists.postgresql.org; Sun, 04 Nov 2018 19:55:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJOUH-00048r-D6 for pgsql-sql@lists.postgresql.org; Sun, 04 Nov 2018 19:55:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wA4Jt7OJ003967; Sun, 4 Nov 2018 14:55:07 -0500 From: Tom Lane To: "Mark Williams" cc: "'A. Sasaki'" , pgsql-sql@lists.postgresql.org Subject: Re: Regular Expressions In-reply-to: <013401d47476$a7acf540$f706dfc0$@gmail.com> References: <012401d47472$0ebc9240$2c35b6c0$@gmail.com> <013401d47476$a7acf540$f706dfc0$@gmail.com> Comments: In-reply-to "Mark Williams" message dated "Sun, 04 Nov 2018 19:43:26 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3965.1541361307.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 04 Nov 2018 14:55:07 -0500 Message-ID: <3966.1541361307@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Mark Williams" writes: > Also, what would be the regular expression if you want to check whether = all the words were in the field where you had say 10 words/phrases you wan= ted to check for? As David said, regular expressions aren't really designed to do that. Personally I'd do the AND at the SQL level, ie myfield ~* '\mtext1\M' AND myfield ~* '\mtext2\M' AND ... You might also take a look at the full text search machinery, which is probably better suited to this task. regards, tom lane