Re: regexp_substr help, please

From: md <mardahl2000_at_yahoo.com>
Date: Tue, 29 Apr 2008 09:52:28 -0700 (PDT)
Message-ID: <00c34c46-6f45-454c-a110-75b43ea5fec5@m44g2000hsc.googlegroups.com>


On Apr 29, 12:43 pm, yf..._at_vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
> Doug Miller (spamb..._at_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";
  }
} Received on Tue Apr 29 2008 - 11:52:28 CDT

Original text of this message