excessive escaping in regular expression functions

From: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: excessive escaping in regular expression functions
Date: 2011-01-18 19:52:16
Message-ID: 5F572960-D55F-49FE-96A6-BCAFB0FFFF9C@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

The following statement replaces an asterisk in a string with a double-escaped asterisk:
SELECT regexp_replace('*',E'\\*',E'\\\\\\\\\*');

I got this result through experimentation and I am at a loss to explain why so much escaping is necessary for the third argument. Is there a better way?

Cheers,
M

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2011-01-18 20:01:13 Re: excessive escaping in regular expression functions
Previous Message araza 2011-01-18 19:35:14 How to get TimeZone name?