pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
postgres 6.3.2 and regexp
3+ messages / 3 participants
[nested] [flat]

* postgres 6.3.2 and regexp
@ 1999-04-18 23:37  Bill Brandt <brandtwr-pgsql@draaw.net>
  0 siblings, 2 replies; 3+ messages in thread

From: Bill Brandt @ 1999-04-18 23:37 UTC (permalink / raw)
  To: pgsql-sql@hub.org

This may have been dealt with before, but I'm encountering a problem with regexp selects in postgres 6.3.2.  Is this a known bug?  

If I insert a value of '*test*' into an field and do a select like:

select * from table where 'This is a test entry'::text~*field;

I get a reply of:

ERROR:  regcomp failed with error repetition-operator operand invalid

This happens anytime the text has a * as the first character. 

-- 
Bill Brandt                                   
brandtwr@draaw.net                              http://www.draaw.net/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] postgres 6.3.2 and regexp
@ 1999-04-19 12:54  Guido Piazzi <gdx@nemo.it>
  parent: Bill Brandt <brandtwr-pgsql@draaw.net>
  1 sibling, 0 replies; 3+ messages in thread

From: Guido Piazzi @ 1999-04-19 12:54 UTC (permalink / raw)
  To: Bill Brandt <brandtwr-pgsql@draaw.net>; +Cc: pgsql-sql@hub.org

On Sun, 18 Apr 1999, Bill Brandt wrote:

> ERROR:  regcomp failed with error repetition-operator operand invalid
> 
> This happens anytime the text has a * as the first character. 

That's because in regular expressions '*' matches zero or more consecutive
occurrences of the previous character, which can't be found when '*' is
the first character in the string.  It's not like unix wildcards.

Maybe you should use 'test' instead of '*test*', because regular
expressions match every string that has the regexp in it, regardless of
what's before and after the regexp in the string.

Moreover, regular expression matching is usually done the other way round,
i.e. "SELECT * FROM table WHERE field ~ 'regexp';".

Hope it helps... Guido

--
Guido Piazzi - Piazza Crivelli, 3 - 20014 Nerviano MI - 0347 9690977
* better get into what you got to get into
  better get into it now no slacking please
  united nations ain't really united
  and the organizations ain't really organized  (Donovan, 1970)






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] postgres 6.3.2 and regexp
@ 1999-04-19 13:38  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bill Brandt <brandtwr-pgsql@draaw.net>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 1999-04-19 13:38 UTC (permalink / raw)
  To: Bill Brandt <brandtwr-pgsql@draaw.net>; +Cc: pgsql-sql@hub.org

Bill Brandt <brandtwr-pgsql@draaw.net> writes:
> This may have been dealt with before, but I'm encountering a problem
> with regexp selects in postgres 6.3.2.  Is this a known bug?
> ERROR:  regcomp failed with error repetition-operator operand invalid
> This happens anytime the text has a * as the first character. 

No bug there.  Better go reread the documentation about regular
expressions again.  (Hint: they're not the same as shell wildcards.)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1999-04-19 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-18 23:37 postgres 6.3.2 and regexp Bill Brandt <brandtwr-pgsql@draaw.net>
1999-04-19 12:54 ` Guido Piazzi <gdx@nemo.it>
1999-04-19 13:38 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox