Re: [GENERAL] Regular expressions syntax: is \ the escape character ?

From: Chris Jones <cjones(at)rightnowtech(dot)com>
To: Gabriel Fernandez <gabi(at)unica(dot)edu>
Cc: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Regular expressions syntax: is \ the escape character ?
Date: 2000-03-07 16:14:30
Message-ID: x64saioizd.fsf@reddwarf.rightnowtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gabriel Fernandez <gabi(at)unica(dot)edu> writes:

> The only problem i have is when i want to escape a single quote (') or the
> backslash (\).
>
> For example: i have one row with the value 'ONE\SECOND'
>
> I try to recover it doing (from psql frontend):
>
> select field1 from table1 where field1 ~* 'ONE\\\' ;

Heh. This will probably work if you use *four* backslashes. The
first time it gets parsed, 'ONE\\\\' -> 'ONE\\', because each '\\'
sequence will reduce to a single '\'. Then the second time it gets
parsed, the '\\' -> '\', which is what you want.

(Haven't tested it, but I've seen similar things in other places.)

Chris

--
---------------------------------------------------- cjones(at)rightnowtech(dot)com
Chris Jones
System Administrator, Right Now Technologies, Inc.
"Is this going to be a stand-up programming session, sir, or another bug hunt?"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Atkins 2000-03-07 16:45:36 Re: DHCP and pg_hba.conf
Previous Message JB 2000-03-07 16:06:56 Re: [GENERAL] 50 MB Table