regexp_substr help, please
- From: spambait@xxxxxxxxxx (Doug Miller)
- Date: Tue, 29 Apr 2008 15:34:24 GMT
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?
.
- Follow-Ups:
- Re: regexp_substr help, please
- From: Peter Nilsson
- Re: regexp_substr help, please
- From: Malcolm Dew-Jones
- Re: regexp_substr help, please
- From: md
- Re: regexp_substr help, please
- Prev by Date: conditional insert with values; insert into .. values(...) where not exist (....);
- Next by Date: Re: regexp_substr help, please
- Previous by thread: conditional insert with values; insert into .. values(...) where not exist (....);
- Next by thread: Re: regexp_substr help, please
- Index(es):
Relevant Pages
|