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

From: Charles Tassell <ctassell(at)isn(dot)net>
To: Gabriel Fernandez <gabi(at)unica(dot)edu>, PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Regular expressions syntax: is \ the escape character ?
Date: 2000-03-03 20:15:35
Message-ID: 4.2.0.58.20000303161200.009fd240@mailer.isn.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You have to use two backslashes, as the preprocessor will take the first
one out (I may be wrong about this, but I remember reading something
similar a few months ago on this list.) Also, remember that you have to
send two slashes to PostGres, which may mean that you need to use 4 slashes
in your code. IE, for a PERL program:

$dbi->prepare("SELECT field FROM table WHERE field ~* '\\+'");

is actually only sending:
SELECT field FROM table WHERE field ~* '\+'
to the backend, so you should use:
$dbi->prepare("SELECT field FROM table WHERE field ~* '\\\\+'");

At 03:04 PM 3/3/00, Gabriel Fernandez wrote:
>Hi,
>
>I'm using regular expressions in 6.5.3 version but i cannot find the
>character to escape special caracters as ?, $, ^.
>
>I've tried with \ but it doesn't works.
>
>Example: i want to find the row with the value 'fisica?' and i do:
>
>select title from libros where title ~* 'fisica\?' ;
>
>but i also obtain rows with values: 'fisicamente' or 'fisicas'
>
>What am i doing wrong ?
>
>Thanks in advance.
>
>Gabi :-)
>
>
>************

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2000-03-03 21:54:47 Re: [GENERAL] FOREIGN KEY syntax
Previous Message Charles Tassell 2000-03-03 19:06:17 Re: [GENERAL] Illegal use of aggregates or non-group column in target list