postgres 6.3.2 and regexp

Поиск
Список
Период
Сортировка
Искать

postgres 6.3.2 and regexp

От:
Bill Brandt <brandtwr-pgsql@draaw.net>
Дата:
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/

Re: [SQL] postgres 6.3.2 and regexp

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bill Brandt  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

Re: [SQL] postgres 6.3.2 and regexp

От:
Guido Piazzi <gdx@nemo.it>
Дата:
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)




FAQ