BUG #10334: Function regexp_split_to_array Error with '.' (comma)

Started by Nonamealmost 12 years ago2 messagesbugs
Jump to latest
#1Noname
danilogarciamartins@hotmail.com

The following bug has been logged on the website:

Bug reference: 10334
Logged by: Danilo
Email address: danilogarciamartins@hotmail.com
PostgreSQL version: 9.2.4
Operating system: Windows 7 64 bits
Description:

Ex.: select regexp_split_to_array('1.2.3','.')
returns {"","","","","",""} and not
{1,2,3}.
Thanks

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: BUG #10334: Function regexp_split_to_array Error with '.' (comma)

danilogarciamartins@hotmail.com writes:

Ex.: select regexp_split_to_array('1.2.3','.')
returns {"","","","","",""} and not
{1,2,3}.

This is not a bug: "." is a wild-card character in regular expressions.
You could get the behavior you're evidently after by escaping it:

# select regexp_split_to_array('1.2.3','\.');
regexp_split_to_array
-----------------------
{1,2,3}
(1 row)

regards, tom lane

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