Search Postgresql Archives

Re: Regex Character-Class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Henry schrieb:
I must be missing something here:

SELECT '1.1.1.1' ~ E'^\d+';

returns FALSE, when I would expect TRUE, as for:

SELECT '1.1.1.1'  ~ E'^[[:digit:]]+';

ie, '[[:digit:]]'  !=  '\d'

In config, "regex_flavor = advanced".

Any ideas?

Yes; you have to escape the backslash character:

=> SELECT '1.1.1.1' ~ E'^\\d+';
 ?column?
----------
 t
(1 row)


See the documentation for this (http://www.postgresql.org/docs/8.3/interactive/functions-matching.html):

  Note:  Remember that the backslash (\) already has a special meaning
  in PostgreSQL string literals. To write a pattern constant that
  contains a backslash, you must write two backslashes in the statement,
  assuming escape string syntax is used (see Section 4.1.2.1).

Ciao,
Thomas

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux