Re: Simple Regex question, hoping for direct answer (no Socratic approach necessary)

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "Postgres User *EXTERN*" <postgres(dot)developer(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Simple Regex question, hoping for direct answer (no Socratic approach necessary)
Date: 2007-08-24 07:08:01
Message-ID: D960CB61B694CF459DCFB4B0128514C218DA2E@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Postgres User wrote:
> I'm new to Regex in Postgres. Can someone give me a quick pointer on
> how I'd SELECT the substring between '<name>' and '</name>' in
> a field?
>
> Sample field data:
> address city here <name>Rogers, Jim</name> zip code place
>
> and I'd like the SELECT to return only:
> Rogers, Jim

SELECT regexp_replace(
'Sing along with <name>Rogers, Jim</name>',
'.*<name>(.*?)</name>.*',
E'\\1');

regexp_replace
----------------
Rogers, Jim
(1 row)

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hannes Dorbath 2007-08-24 07:17:47 Re: Apache + PHP + Postgres Interaction
Previous Message Michael Glaesemann 2007-08-24 06:47:10 Re: %TYPE