Skip site navigation (1) Skip section navigation (2)

POSIX Escape

From: Howard Cole <howardnews(at)selestial(dot)com>
To: 'PgSql General' <pgsql-general(at)postgresql(dot)org>
Subject: POSIX Escape
Date: 2008-06-25 19:27:57
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Hello All,

Apologies if this is a bit off-topic. Any hints as to what character 
sequences need escaping in Postgres's regular expressions?

Let me show you the problem.

If I want to find all strings that start with 'postgres' I use the regex

select str ~ '^postgres'.

However if str contains reserved meta characters, e.g. +(-)[.]{} etc 
then I need to escape that sequence somehow? e.g. to find a string 
starting 'fish + chips' I need to escape for regex and then postgres.

select str ~ '^fish\\s\\+\\schips''

Has anyone got a definitive list of replacements that are required for 
Postgres's version of Regular Expressions?


pgsql-general by date

Next:From: Alvaro HerreraDate: 2008-06-25 19:35:12
Subject: Re: 0xc3 error Text Search Windows French
Previous:From: Chris BrowneDate: 2008-06-25 18:58:35
Subject: Re: Probably been asked a hundred times before.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group