posix style regexp? - Mailing list pgsql-general

From Cindy
Subject posix style regexp?
Date
Msg-id 21806.1032372777@stephanus.tlg.uci.edu
Whole thread Raw
Responses Re: posix style regexp?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I've a question about escaping special characters in a ~ string operation.
To match the literal ? I would have thought I could put in \?
but this seems not to work.

Examples:
Text=# SELECT byteloc, citation FROM citations WHERE aid = 1262::smallint AND wid = 2::smallint AND citation ~
'y"335?"z[0-9]+';
 byteloc | citation
---------+----------
(0 rows)
Text=# SELECT byteloc, citation FROM citations WHERE aid = 1262::smallint AND wid = 2::smallint AND citation ~
'y"335\?"z[0-9]+';
 byteloc | citation
---------+----------
(0 rows)
Text=# SELECT byteloc, citation FROM citations WHERE aid = 1262::smallint AND wid = 2::smallint AND citation ~
'y"335."z[0-9]+';
 byteloc | citation
---------+-----------
     160 | y"335?"z1
     215 | y"335?"z2
     276 | y"335?"z3
     341 | y"335?"z4
     410 | y"335?"z5
     467 | y"335?"z6
     530 | y"335?"z7
(7 rows)


Thanks,
--Cindy
--
ctmoore@uci.edu

pgsql-general by date:

Previous
From: Eric D Nielsen
Date:
Subject: Permissions with multiple groups...
Next
From: Neil Conway
Date:
Subject: Re: Automatic Indexes from Query Optimization?