Home Postgres Regex to Return first word before comma and first word after
 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?