Home Postgres Regex to Return first word before comma and first word after
Reply: 0

Postgres Regex to Return first word before comma and first word after

user504
1#
user504 Published in April 24, 2018, 10:14 pm

I am trying to get the first and last name from a column using regex but I'm stumped.

I'm trying:

select
    substring('SMIRTH JR, DAVID ALLEN', '^[^ ,]+') as namemodified

it should return

SMIRTH, DAVID

but it only returns the last name. I can't figure out how to get both.

I also need it to work for:

SMIRTHJR, DAVID ALLEN

since the data isn't very clean. Any ideas?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307773 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO