
実行環境
••
•
テーブルに、切り出し後を保存する列を追加
作業は8# \d kenpg_seesaa_list Table "public.kenpg_seesaa_list" +-----------+------+-----------+ | Column | Type | Modifiers | +-----------+------+-----------+ | ymd | date | | | url | text | | | title | text | | | tags | text | | | html_file | text | | | html | text | |<- contents +-----------+------+-----------+
列
# alter table kenpg_seesaa_list add body text; # alter table kenpg_seesaa_list add primary key (ymd); alter table kenpg_seesaa_list alter url set not null; alter table kenpg_seesaa_list alter title set not null; alter table kenpg_seesaa_list alter tags set not null; alter table kenpg_seesaa_list alter html_file set not null; alter table kenpg_seesaa_list alter html set not null; create unique index on kenpg_seesaa_list (url); # \d kenpg_seesaa_list Table "public.kenpg_seesaa_list" +-----------+------+-----------+ | Column | Type | Modifiers | +-----------+------+-----------+ | ymd | date | not null | | url | text | not null | | title | text | not null | | tags | text | not null | | html_file | text | not null | | html | text | not null | | body | text | | +-----------+------+-----------+ Indexes: "kenpg_seesaa_list_pkey" PRIMARY KEY, btree (ymd) "kenpg_seesaa_list_url_idx" UNIQUE, btree (url)

正規表現での切り出しを SELECT 文で確認してから UPDATE
旧ブログのうち切り出し結果を全部表示すると見づらいので、left
# select ymd, left(r[1], 30) || '...' || right(r[1], 30) from kenpg_seesaa_list, regexp_matches(html, 'main_article">(.+)' || '