TransWikia.com

Postgres normalize human name string

Database Administrators Asked on December 24, 2021

Is there some function to normalize name string:

 select normalize('R.C. Bray') 

 'R. C. Bray'

Or the opposite direction?

The simple replace('. ', '.') or replace('.', '. ') is wrong and may be effect another data.

2 Answers

regexp_replace should be enough:

regexp_replace('R.C. Bray.', '([A-Z])(.)(w)', '12 3', 'g') 

This replaces a single upper case letter followed by a . directly followed by a "word character" by inserting a space between the dot and the character. It leaves dots that have a whitespace after them untouched.

Answered by a_horse_with_no_name on December 24, 2021

select  regexp_replace(array_to_string(string_to_array('R.C. Bray', '.'), '. '), '[ ]+', ' ', 'g');

Can be work. But may be not a good method.

Answered by jiamo on December 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP