|
|
|
Re: How to extract first 3 characters from each word in a string/sentence and separate with underscore? [message #599261 is a reply to message #599252] |
Wed, 23 October 2013 06:32   |
Solomon Yakobson
Messages: 3305 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
raksh1986 wrote on Wed, 23 October 2013 06:22The Query below helped me to achieve partially.
Gross overkill:
column new_str format a30
with t as (
select 'Net Amount Payable by an Individual' str from dual union all
select 'Net Amount Payable by an Individual+Tax' from dual union all
select 'Total Amount Payable towards Service' from dual union all
select 'Total Amount Payable towards Service.+Tax' from dual
)
select str,
rtrim(regexp_replace(str,'(\w{1,3})\w*(\W+|$)','\1_'),'_') new_str
from t
/
STR NEW_STR
----------------------------------------- ------------------------------
Net Amount Payable by an Individual Net_Amo_Pay_by_an_Ind
Net Amount Payable by an Individual+Tax Net_Amo_Pay_by_an_Ind_Tax
Total Amount Payable towards Service Tot_Amo_Pay_tow_Ser
Total Amount Payable towards Service.+Tax Tot_Amo_Pay_tow_Ser_Tax
SCOTT@orcl >
SY.
|
|
|
|