![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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? |
#3
| |||
| |||
|
|
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? |
#4
| |||
| |||
|
|
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? |
#5
| |||
| |||
|
|
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? |
#6
| |||
| |||
|
|
Doug Miller (spamb... (AT) milmac (DOT) 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 |
#7
| |||
| |||
|
|
Doug Miller (spamb... (AT) milmac (DOT) 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 |
#8
| |||
| |||
|
|
Doug Miller (spamb... (AT) milmac (DOT) 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 |
#9
| |||
| |||
|
|
Doug Miller (spamb... (AT) milmac (DOT) 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 |
#10
| |||
| |||
|
|
Doug Miller (spambait (AT) milmac (DOT) 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |