Re: [GENERAL] Regular expressions syntax: is \ the escape character ? - Mailing list pgsql-general

From Charles Tassell
Subject Re: [GENERAL] Regular expressions syntax: is \ the escape character ?
Date
Msg-id 4.2.0.58.20000303161200.009fd240@mailer.isn.net
Whole thread Raw
In response to Regular expressions syntax: is \ the escape character ?  (Gabriel Fernandez <gabi@unica.edu>)
List 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 :-)
>
>
>************


pgsql-general by date:

Previous
From: Charles Tassell
Date:
Subject: Re: [GENERAL] Illegal use of aggregates or non-group column in target list
Next
From: "Oliver Elphick"
Date:
Subject: Re: [GENERAL] FOREIGN KEY syntax