![]() | |
![]() |
| | Thread Tools | Display Modes |
#21
| |||
| |||
|
|
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 |
|
| '(' -- with comma | '([^,]*)' -- surname | ', *' | '(.*)' -- given name(s) | ')' | '|' | '(' -- without comma | '(' -- surname | '((mc|st)\.?)? *' -- optional prefix | '[^ ]+' | ')' | ' *' | '(.*)' -- given name(s) | ')' | '$', '"\2\5", "\3\8"', -- "surname", "given" |
![]() |
| Thread Tools | |
| Display Modes | |
| |