Wednesday, June 25, 2008

[GENERAL] POSIX Escape

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?

Howard.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

No comments: