Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
berryandcherry6
Creator II
Creator II

Rename string containing specific characters

Hi,

i have a string, and i need to check whether that string contains specific strings and rename it.

StringName                                                                         Renamed_string

FTC MNC and CC refund_23-03-2017_29-03-2017            MNC and CC

NC-MNC_23-03-2017_29-03-2017                                    MNC

Y MNC and CC_23-03-2017_29-03-2017                           MNC and CC

WRTE MNC_23-03-2017_29-03-2017                               MNC

WRTE MNC and CC_23-03-2017_29-03-2017                  MNC and CC

MNC_23-03-2017_29-03-2017                                         MNC

Y-MNC & CC_23-03-2017_29-03-2017                             MNC and CC

MNC refund_23-03-2017_29-03-2017                               MNC

MNC & CC_23-03-2017_29-03-2017                                MNC and CC

MNC_23-03-2017_29-03-2017                                         MNC

MNCCC_23-03-2017_29-03-2017                                   MNC and CC

CC_23-03-2017_29-03-2017                                            CC

If in given string it contains only MNC, i need renamed string to be MNC.

If it contains both MNC and CC, i need to rename string as MNC and CC.

This renamed string is to added as onemore column to table.

Script;

Load  StringName;

SQL SELECT  StringName

from MyTable;

How could i do this?.

1 Solution

Accepted Solutions
Anil_Babu_Samineni

May be this?

LOAD StringName, If(SubStringCount(StringName,'MNC') and SubStringCount(StringName,'CC'),'MNC CC','CC') as StringName1 Inline [

StringName                                                                        

FTC MNC and CC refund_23-03-2017_29-03-2017

NC-MNC_23-03-2017_29-03-2017

Y MNC and CC_23-03-2017_29-03-2017

WRTE MNC_23-03-2017_29-03-2017

WRTE MNC and CC_23-03-2017_29-03-2017

MNC_23-03-2017_29-03-2017

Y-MNC & CC_23-03-2017_29-03-2017

MNC refund_23-03-2017_29-03-2017

MNC & CC_23-03-2017_29-03-2017

MNC_23-03-2017_29-03-2017

MNCCC_23-03-2017_29-03-2017

CC_23-03-2017_29-03-2017

];

Capture.PNG

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

6 Replies
satheshreddy
Creator III
Creator III

Hi Supriya,

can you elaborate the query?

you saying you need to know the string is same are renamed?

Regards

Sathish

berryandcherry6
Creator II
Creator II
Author

Hi,

If in given string it contains only MNC, i need renamed string to be MNC.

If it contains both MNC and CC, i need to rename string as MNC and CC.

This renamed string is to added as onemore column to table.

Anil_Babu_Samineni

May be this?

LOAD StringName, If(SubStringCount(StringName,'MNC') and SubStringCount(StringName,'CC'),'MNC CC','CC') as StringName1 Inline [

StringName                                                                        

FTC MNC and CC refund_23-03-2017_29-03-2017

NC-MNC_23-03-2017_29-03-2017

Y MNC and CC_23-03-2017_29-03-2017

WRTE MNC_23-03-2017_29-03-2017

WRTE MNC and CC_23-03-2017_29-03-2017

MNC_23-03-2017_29-03-2017

Y-MNC & CC_23-03-2017_29-03-2017

MNC refund_23-03-2017_29-03-2017

MNC & CC_23-03-2017_29-03-2017

MNC_23-03-2017_29-03-2017

MNCCC_23-03-2017_29-03-2017

CC_23-03-2017_29-03-2017

];

Capture.PNG

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
satheshreddy
Creator III
Creator III

Hi Anil,

sorry for ask,

if the data is in database we should write like above are need to change something.

Regards

sathish

Anil_Babu_Samineni

Why Sorry, When we open things then we learn.

Yes, We can do same thing

Connect String

//Preceding Load here like as i mentione

Load * From Table;

Select * From Table;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
satheshreddy
Creator III
Creator III

Hi,

ok i got the point.

Regards

Sathish