Path: text.usenetserver.com!out04a.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!postnews.google.com!m44g2000hsc.googlegroups.com!not-for-mail
From: md <mardahl2000@yahoo.com>
Newsgroups: comp.databases.oracle.misc
Subject: Re: regexp_substr help, please
Date: Tue, 29 Apr 2008 09:52:28 -0700 (PDT)
Organization: http://groups.google.com
Lines: 41
Message-ID: <00c34c46-6f45-454c-a110-75b43ea5fec5@m44g2000hsc.googlegroups.com>
References: <4eHRj.3091$1b7.1785@newssvr13.news.prodigy.net> 
 <4817502b$1@news.victoria.tc.ca>
NNTP-Posting-Host: 205.215.195.253
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1209487948 16748 127.0.0.1 (29 Apr 2008 16:52:28 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 29 Apr 2008 16:52:28 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: m44g2000hsc.googlegroups.com; posting-host=205.215.195.253; 
 posting-account=f5S04QkAAAD2QGj5llar3qetuG3qiyvw
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) 
 Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)
Xref: usenetserver.com comp.databases.oracle.misc:252584
X-Received-Date: Tue, 29 Apr 2008 12:52:28 EDT (text.usenetserver.com)

On Apr 29, 12:43 pm, yf...@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
wrote:
> Doug Miller (spamb...@milmac.com) 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
>
> [A-Z] doesn't match o

Here a perl test I did to check out a maybe.
@ is an array of your combos (did I get them all?)
The loop goes thru each.  $1 will contain the "last name".


@s = ("mc winter, first",
   "mc. winter, first",
   "winter, first",
   "mc winter,first",
   "mc. winter,first",
   "winter,first",
   "mc winter first",
   "mc. winter first",
   "winter first",
   );

foreach $x (@s) {
  print qq/look at "$x"\n/;
  {
  $x =~ /(.*)?[, ]{1}[a-zA-Z]*$/;
  print $1 . "\n";
  }
}

