pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Leif B. Kristensen <leif@solumslekt.org>
To: Ian Barwick <barwick@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Plpgsql: Assign regular expression match to variable
Date: Tue, 1 Sep 2009 14:56:18 +0200
Message-ID: <200909011456.18519.leif@solumslekt.org> (raw)
In-Reply-To: <1d581afe0909010536g6fdb57a0u87c8d748fb9067b6@mail.gmail.com>
References: <200909011401.00231.leif@solumslekt.org>
	<1d581afe0909010536g6fdb57a0u87c8d748fb9067b6@mail.gmail.com>

On Tuesday 1. September 2009, Ian Barwick wrote:

>This seems to do what you want:
>
>  my_int := (REGEXP_MATCHES(txt, E'^#(\\d+)'))[1];

Great! I had no idea that REGEXP_MATCHES() could do that kind of stuff.

pgslekt=> select (REGEXP_MATCHES('#42 blabla', E'^#(\\d+)'))
[1]::integer;
 regexp_matches
----------------
             42
(1 row)

Thank you very much.
-- 
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/



view thread (3+ messages)

Message-ID: <200909011456.18519.leif@solumslekt.org>
Permalink:  ../200909011456.18519.leif@solumslekt.org/
Also on:    postgresql.org/message-id/200909011456.18519.leif@solumslekt.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: leif@solumslekt.org, barwick@gmail.com
  Subject: Re: Plpgsql: Assign regular expression match to variable
  In-Reply-To: <200909011456.18519.leif@solumslekt.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox