Received: from candle.pha.pa.us (pgman@nav-43.dsl.navpoint.com [162.33.245.46]) by hub.hub.org (8.10.1/8.10.1) with ESMTP id e9FIqgq56038 for ; Sun, 15 Oct 2000 14:52:42 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id OAA11290; Sun, 15 Oct 2000 14:50:46 -0400 (EDT) From: Bruce Momjian Message-Id: <200010151850.OAA11290@candle.pha.pa.us> Subject: Re: Regular expression query In-Reply-To: <825.967177355@sss.pgh.pa.us> "from Tom Lane at Aug 25, 2000 00:22:35 am" To: Tom Lane Date: Sun, 15 Oct 2000 14:50:46 -0400 (EDT) CC: rodgerd@diaspora.gen.nz, pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL77 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200010/132 X-Sequence-Number: 1794 > Rodger Donaldson writes: > > SELECT url > > FROM sites > > WHERE url ~ url || '\\s+' > > > While this concatenation works with the LIKE directive (ie LIKE url || '%'), > > postgresql barfs on it in a regexp with the error: > > > ERROR: Unable to identify an operator '||' for types 'bool' and 'unknown' > > You will have to retype this query using an explicit cast > > LIKE and ~ do not have the same precedence. See > http://www.postgresql.org/docs/postgres/operators.htm. > ~ and || actually fall in the same category ("all other") and therefore > are grouped left-to-right; so you're getting (url ~ url) || '...'. > > > The other aspect of this is that it seems that postgresql's regexp engine > > doesn't understand some expected regexps; I've tried both escaped and > > unescaped versions of, eg \w, \s, \n and so on a pg seems to ignore them. > > The regexp package we currently use implements POSIX 1003.2 regexps > (see src/backend/regex/re_format.7). I believe there is an item on the > TODO list about upgrading the regexp parser to something more modern > ... feel free to hop on that project if it's bugging you ... I bug Henry Spencer regularly. His new code is in TCL/TK, but has not been released into any other code. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026