pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Peter Eisentraut <peter@pathwaynet.com>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Escaping w/i regular expressions
Date: Sun, 4 Jul 1999 14:09:33 +0300
Message-ID: <l03130302b3a4f0d44027@[147.233.159.109]> (raw)
In-Reply-To: <Pine.LNX.4.10.9906301406440.30903-100000@uruguay.pathwaynet.com>

At 21:07 +0300 on 30/06/1999, Peter Eisentraut wrote:


> How do you escape a ' (apostrophe) within a regular expression, so it does
> not close off the string? Something like
>    ... ~ '[0-9.,\']'
> does not seem to work.
> (Pgsql 6.4.2)

Yes, it does work:

testing=> select * from test;
nm
-------------------------------------------------------
This is a regular sentence ending with a full stop.
In this sentence there is a 'quoted' word.
not a sentence
Fi, fye, foe, fam - I smell the blood of an Englishman.
There are 10,000 bottles of beer on the wall.
(5 rows)

testing=> select * from test where nm ~ '[0-9.,\']';
nm
-------------------------------------------------------
This is a regular sentence ending with a full stop.
In this sentence there is a 'quoted' word.
Fi, fye, foe, fam - I smell the blood of an Englishman.
There are 10,000 bottles of beer on the wall.
(4 rows)

See how it didn't match the 'not a sentence'? Now, to make sure, I removed
the '.' from your regular expression, so the only thing to match in the
'quoted' row was the quotes:

testing=> select * from test where nm ~ '[0-9,\']';
nm
-------------------------------------------------------
In this sentence there is a 'quoted' word.
Fi, fye, foe, fam - I smell the blood of an Englishman.
There are 10,000 bottles of beer on the wall.
(3 rows)

Convinced?

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (4+ messages)  latest in thread

Message-ID: <l03130302b3a4f0d44027@[147.233.159.109]>
Permalink:  ../l03130302b3a4f0d44027@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130302b3a4f0d44027@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, peter@pathwaynet.com
  Subject: Re: [SQL] Escaping w/i regular expressions
  In-Reply-To: <l03130302b3a4f0d44027@[147.233.159.109]>
  References: <Pine.LNX.4.10.9906301406440.30903-100000@uruguay.pathwaynet.com> <l03130302b3a4f0d44027@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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