My string is KCKAN7987682, I want the output as AN7987682. Which means anything before AN needs to be removed. I have to do this for 1000 records in excel.Kindly help!

My string is KCKAN7987682, I want the output as AN7987682. Which means anything before AN needs to be removed. I have to do this for 1000 records in excel.Kindly help!

1 Like

Use substring method. Take AN as the starting index and get the respective substring . Replace the current value with the substring.
Use for each row loop for this operation.

Hi,

Yes you can use like this
strvariable.substring(3).tostring

1 Like

Hi
if the input is str_input = “KCKAN7987682”

Then the expression be like this in assign activity
str_output = “AN”+Split(str_input,”AN”)(1).ToString

If it’s from a excel
Then
—use a excel application scope and pass the file path as input
—inside the scope use a read range activity and get the output with a variable of type datatable named dt
—now use a for each row activity and pass the variable dt as input
—inside the loop use a assign activity and mention like this
row(“yourcolumnname”) = “AN”+Split(row(“yourcolumnname”).ToString.Trim,”AN”)(1).ToString

This will trim all the values in your datatable and it can be written back to excel with WRITE RANGE ACTIVITY where pass the same dt as input and enable add headers property

Cheers @Mahalakshmi

@Mahalakshmi

Try like this.

   inputStr = "KCKAN7987682"
   requiredStr = "AN"+inputStr.Split("AN"c)(1)

You can use the following expression -

finalString = yourString.SubString(yourString.IndexOf("AN"))

Regards,
Karthik Byggari

6 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.