Re: regexp_substr help, please

From: md <mardahl2000_at_yahoo.com>
Date: Tue, 29 Apr 2008 09:33:53 -0700 (PDT)
Message-ID: <cec3e167-20e5-439d-9961-11b1d56399a2@c65g2000hsa.googlegroups.com>


On Apr 29, 10:34 am, spamb..._at_milmac.com (Doug Miller) wrote:
> I need to be able to pull just the last name out of a string consisting of
> lastname and firstname, separated by a comma, or space, or comma and space.
> Complicating matters somewhat is the fact that lastname might be something
> like "Mc Kay" or "St. Louis" so simply grabbing everything before the first
> space isn't sufficient.
>
> The closest I've come so far is
> select regexp_substr ('St. Louis, Ted', '.{4}[A-Z]+') from dual;
> but this returns only
> St. L
>
> I thought regular expression matching was supposed to be "greedy", and take as
> many characters as would satisfy the pattern ("St. Louis" in this case).
>
> What am I doing wrong?

These are you combos?

ln,fn|ln, fn|ln fn
l n,fn|l n, fn|l n fn

I'd start by nuking the fn. It's the last solid string and it has an nice anchor fn$ Received on Tue Apr 29 2008 - 11:33:53 CDT

Original text of this message