Re: Regular Expression Question

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: Terry Lee Tucker <terry(at)esc1(dot)com>
Cc: PostgreSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regular Expression Question
Date: 2005-12-03 17:22:58
Message-ID: 1133630578l.28211l.1l@mofo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 12/03/2005 05:48:59 AM, Terry Lee Tucker wrote:
> RE Gurus:
>
> I have a situation where I need to extract a couple pieces of
> information from
> a string. The string, if entered perfectly by the user, would look
> someting
> like this: DUN: 006235835 SID: KT-3616*
>
> I need to extract the 006235835 into one variable and the KT-3616 into
>
> another. Both "numbers" can possibly be something other than numbers
> alone as
> in the SID: part of the string above. I have come up with a way of
> extracting
> both pieces of information where, at least in my mind, the key
> parameters are
> the colon (:) and a space, as in the first case, or asterik (*), as in
> the
> second case, marking the end of the string to extract.

I would tend to use split_part() and avoid regular expressions
altogether.

select split_part('DUN: 006235835 SID: KT-3616*', ' ', 2);

Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-12-03 17:38:16 Re: PostgresSQL Halting System Boot
Previous Message Karl O. Pinc 2005-12-03 17:15:52 Re: New.* and old.* as function arguments within rules