Re: POSIX RE starting with a (
От | Oliver Elphick |
---|---|
Тема | Re: POSIX RE starting with a ( |
Дата | |
Msg-id | 1092236819.11679.1152.camel@linda обсуждение исходный текст |
Ответ на | POSIX RE starting with a ( (Nick Barr <nicky@chuckie.co.uk>) |
Список | pgsql-general |
On Wed, 2004-08-11 at 14:39, Nick Barr wrote: > Hi, > > Just noticed something funny with the POSIX Regular expressions and > wondered if it is a bug, or whether I am doing something wrong. I am > using the POSIX RE in a function that is used in several places so would > have to put some nasty if statement in there for this side case if there > is not work around. > > ====================================================================== > intranet=# select track_id, track_name from ms_track where track_name > like '(%'; > track_id | track_name > ----------+--------------------------------- > 1294 | (I Can''t Get No) Satisfaction > 1340 | (Hidden Track) > 1503 | (Nice Dream) > 1942 | (I) Get Lost > (4 rows) > > intranet=# select track_name from ms_track where track_name ~ '^\('; > ERROR: invalid regular expression: parentheses () not balanced > intranet=# select track_name from ms_track where track_name ~ '^('; > ERROR: invalid regular expression: parentheses () not balanced > intranet=# select track_name from ms_track where track_name ~ '^\('; > ERROR: invalid regular expression: parentheses () not balanced > ====================================================================== > > Now I have tried a similar query using the PHP POSIX Regular Expressions > and it accepts the sequence '^\(' and matches correctly. Is this a > "feature" of PG that cannot be worked around easily? You need to escape the backslash: select track_name from ms_track where track_name ~ '^\\ ('; -- Oliver Elphick olly@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA ======================================== "Be still before the LORD and wait patiently for him; do not fret when men succeed in their ways, when they carry out their wicked schemes." Psalms 37:7
В списке pgsql-general по дате отправления: