Re: How to get normalized data from tekst column - Mailing list pgsql-general

From Harald Fuchs
Subject Re: How to get normalized data from tekst column
Date
Msg-id 86ipm9ebke.fsf@protecting.net
Whole thread Raw
In response to How to get normalized data from tekst column  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
"Andrus" <kobruleht2@hot.ee> writes:

> David,
>>Regular Expressions are your friend here.  If you do not know them you
> should learn them; though if you ask nicely someone may just provide you
> the solution you need.
>>Split-to-array and unnest may work as well.
>
> Thank you very much. I dona**t know regexps.
> Can you provide example, please for 8.1. Or maybe CASE WHEN and substring
> testing can also used.

The query

SELECT id, a[1] AS name, a[2] AS percent
FROM (
    SELECT id, regexp_split_to_array(regexp_split_to_table(comment, ', *'), '\W+') AS a
    FROM project
  ) AS dummy

should work un every halfway recent PostgreSQL version - dunno about 8.1.

pgsql-general by date:

Previous
From: Phoenix Kiula
Date:
Subject: Re: Incremental backup with RSYNC or something?
Next
From: Adrian Klaver
Date:
Subject: Re: "CREATE TABLE table_name AS EXECUTE name WITH DATA" becomes syntax error.