Re: [HACKERS] postgresql regular expr bug?

2009-06-14 Thread Pavel Stehule
2009/6/14 hubert depesz lubaczewski :
> On Sun, Jun 14, 2009 at 08:15:55AM +0200, Pavel Stehule wrote:
>> postgres=# select '10' ~ '[0..9]+$';
>>  ?column?
>> --
>>  t
>> (1 row)
>
> regexp '[0..9]+$' tests is given strings containst at the end substring
> containing only characters "0", "9" and ".".
> and yes, it does - the last character is 0, so it matches.
>
>> postgres=# select '10' ~ '^[0..9]+$';
>>  ?column?
>> --
>>  f
>> (1 row)
>
> this regexp checks if whole string is built only with characters "0",
> "9", and ".". and it is not - the first character is "1" which is not
> the character list you provided.
>
> basically ".." has no special meaning in regexps, especially within [] -
> i.e. it is just a dot.
>

my mistake

thank you

Pavel

> Best regards,
>
> depesz
>
> --
> Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
> jid/gtalk: dep...@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007
>

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


Re: [HACKERS] postgresql regular expr bug?

2009-06-14 Thread hubert depesz lubaczewski
On Sun, Jun 14, 2009 at 08:15:55AM +0200, Pavel Stehule wrote:
> postgres=# select '10' ~ '[0..9]+$';
>  ?column?
> --
>  t
> (1 row)

regexp '[0..9]+$' tests is given strings containst at the end substring
containing only characters "0", "9" and ".".
and yes, it does - the last character is 0, so it matches.

> postgres=# select '10' ~ '^[0..9]+$';
>  ?column?
> --
>  f
> (1 row)

this regexp checks if whole string is built only with characters "0",
"9", and ".". and it is not - the first character is "1" which is not
the character list you provided.

basically ".." has no special meaning in regexps, especially within [] -
i.e. it is just a dot.

Best regards,

depesz

-- 
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: dep...@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

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


Re: [HACKERS] postgresql regular expr bug?

2009-06-13 Thread Stephen J. Butler
On Sun, Jun 14, 2009 at 1:15 AM, Pavel Stehule wrote:
> can somebody explain this behave?
>
> postgres=# select '10' ~ e'^\\d+$';
>  ?column?
> --
>  t
> (1 row)
> ok
>
> postgres=# select '10' ~ '[0..9]+$';
>  ?column?
> --
>  t
> (1 row)
> ok
>
> postgres=# select '10' ~ '^[0..9]+$';
>  ?column?
> --
>  f
> (1 row)

Try '^[0-9]+$'.

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


[HACKERS] postgresql regular expr bug?

2009-06-13 Thread Pavel Stehule
Hello

can somebody explain this behave?

postgres=# select '10' ~ e'^\\d+$';
 ?column?
--
 t
(1 row)
ok

postgres=# select '10' ~ '[0..9]+$';
 ?column?
--
 t
(1 row)
ok

postgres=# select '10' ~ '^[0..9]+$';
 ?column?
--
 f
(1 row)
?
postgres=# select version();
  version
---
 PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
4.4.0 20090506 (Red Hat 4.4.0-4)
(1 row)

tested on fedora 11

Regards
Pavel Stehule

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