Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T94Sz-0004MA-Bw for pgsql-bugs@postgresql.org; Wed, 05 Sep 2012 01:31:41 +0000 Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T94Su-0005tW-Tg for pgsql-bugs@postgresql.org; Wed, 05 Sep 2012 01:31:41 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T94St-0004ea-KP for pgsql-bugs@postgresql.org; Wed, 05 Sep 2012 01:31:35 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1T94Ss-0003Bc-WF for pgsql-bugs@postgresql.org; Wed, 05 Sep 2012 01:31:35 +0000 Date: Wed, 05 Sep 2012 01:31:34 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7520: regexp_matches does not work as expected To: pgsql-bugs@postgresql.org From: sbasurto@soft-gator.com X-Pg-Spam-Score: -2.1 (--) X-Archive-Number: 201209/31 X-Sequence-Number: 34026 The following bug has been logged on the website: Bug reference: 7520 Logged by: Sergio Basurto Email address: sbasurto@soft-gator.com PostgreSQL version: 9.1.4 Operating system: Gentoo Description: = I am using regexp_matches in a function like this create or replace function test (v_string in text) returns varchar as $$ declare i_strings text[]; i_string text[]; i_strings :=3D regexp_matches(v_string,E'[a-zA-Z0-9:\\s\\-\\.#%]*:[A-Za-z0-9\\s\\-\\.#%]+'= ,'g'); The I use the results = foreach i_string slice 1 in array i_strings loop raise notice 'row =3D %',i_string; end loop; when I run the function like this select test('1:Warehouse1;2:Warehouse2;'); postgresql complains: ERROR: query "SELECT regexp_matches(v_string,E'[a-zA-Z0-9:\\s\\-\\.#%]*:[A-Za-z0-9\\s\\-\\.#%]+'= ,'g')" returned more than one row Off course I am expecting more than one row! If I run: select regexp_matches('1:Warehouse1;2:Warehouse2;',E'[a-zA-Z0-9:\\s\\-\\.#%]*:[A-Z= a-z0-9\\s\\-\\.#%]+','g'); regexp_matches = ---------------- {1:Warehouse1} {2:Warehouse2} (2 rows)