Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Regular Expressions Functions
 

Convert a name in the form first middle last into the last, middle first format

SQL> SQL> SELECT REGEXP_REPLACE('Hubert Horatio Hornblower',   2      '(.*) (.*) (.*)',   3      '\3, \2 \1') "Reformatted Name"   4  FROM dual ; Reformatted Name -------------------------- Hornblower, Horatio Hubert SQL>