pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: gurkan@resolution.com
Cc: pgsql-sql@postgresql.org
Subject: Re: regular expression
Date: Tue, 4 Oct 2005 23:56:05 -0600
Message-ID: <20051005055605.GA53834@winnie.fuhr.org> (raw)
In-Reply-To: <1128377310.4341abde55776@www.resolution.com>
References: <1128377310.4341abde55776@www.resolution.com>

On Mon, Oct 03, 2005 at 06:08:30PM -0400, gurkan@resolution.com wrote:
> How do I do regular expression for the problem that I am having
> I have a string called desc, and say that this string in 
> 
> "TSWUU"          ------ ""
> "4 - DSC"        ------ "4"
> "6768 - THY"     ------ "6768"
> 
>  basically string may or may not start with number, 
> I need substring of digits parts
> ""
> "4"
> "6768"

See "Pattern Matching" in the documentation:

http://www.postgresql.org/docs/8.0/interactive/functions-matching.html

Example:

test=> SELECT id, data FROM foo;
 id |    data    
----+------------
  1 | TSWUU
  2 | 4 - DSC
  3 | 6768 - THY
(3 rows)

test=> SELECT id, substring(data FROM '^([[:digit:]]+)') FROM foo;
 id | substring 
----+-----------
  1 | 
  2 | 4
  3 | 6768
(3 rows)

-- 
Michael Fuhr



view thread (5+ messages)  latest in thread

Message-ID: <20051005055605.GA53834@winnie.fuhr.org>
Permalink:  ../20051005055605.GA53834@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20051005055605.GA53834@winnie.fuhr.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: mike@fuhr.org, gurkan@resolution.com
  Subject: Re: regular expression
  In-Reply-To: <20051005055605.GA53834@winnie.fuhr.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