简体   繁体   中英

INITCAP function with few exceptions

Hey i have requirement to initcap the column name; with exception for few strings.

Source
THE BANK OF AMERICA
BANK OF BARODA
SEABANK OF INDIA

target
The BANK Of America
BANK Of Baroda
SeaBANK of INDIA

in this case i want t Initcap the incoming string but i need to retain the "BANK" value and "INDIA" as is.

SELECT REGEXP_REPLACE (
          REGEXP_REPLACE (INITCAP ('SEABANK OF INDIA'), '(B|b)ank', 'BANK'),
          '(I|i)ndia',
          'INDIA')
  FROM DUAL;

Output:

SeaBANK Of INDIA

SELECT REPLACE(REPLACE(REPLACE(initcap('THE BANK OF AMERICA 
BANK OF BARODA 
SEABANK OF INDIA'), 'Bank', 'BANK'), 'India', 'INDIA'),'bank', 'BANK') 
FROM dual;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM