String manipulation 1

I have a list of names written as below -

Nirmalya-Sarkar
Vijay-Agarwal
Suman-Saha
Rakesh-Dey
Anuj-Patel
Neil-Nitin-Mukesh

I have to replace “-” and put “*” in those names.

What is the correct solution?

Thanks & Regards,
Nirmalya Sarkar

1 Like

U can try regex option

Use the replace activity for regex or use the below code

System.Text.RegularExpressions.Regex.Replace(inputstring,“-”,“*”)

Try this @nirmalya.sarkar

Regards

Nived N :robot:

Happy Automation

Hi @nirmalya.sarkar

Let’s take it in a simple way

If the above value is in a variable named str_input

Then use a Assign activity and mention like this

Str_output = str_input.ToString.Replace(“-“,”*”).ToString

Where str_output is a variable of type string

Cheers

1 Like

Hey @nirmalya.sarkar

@Palaniyappan and @NIVED_NAMBIAR have already responded but I would strongly recommend bookmarking this great String Manipulation MegaPost form @Adrian_Star.

Cheers

Steve

4 Likes

@Palaniyappan ,

Where am I incorrect? Can you tell me?

Thanks & Regards,
Nirmalya

1 Like

@NIVED_NAMBIAR , I have done your steps. But I want to write the output in excel sheet. Please Share the steps.

Thanks & Regards,
Nirmalya Sarkar

U can build a datatable using build datatable activity and then use add datarow to add each data one by one .

Regards,
Nived N

Fine
May I know how you want the output to be. An image of the required output would help

@nirmalya.sarkar

@Palaniyappan , the output should be -

NirmalyaSarkar
Vijay
Agarwal
SumanSaha
Rakesh
Dey
Anuj*Patel

Thanks & Regards,
Nirmalya

So you want this to be written in a single column in a datatable
@nirmalya.sarkar

@Palaniyappan ,yes in a excel sheet.

Fine
Hope these steps would help you resolve this

—use the above steps for replacing - with *
Once the str_output is ready use a assign activity like this
Arr_input = Split(str_output,Environment.Newline.ToCharArray)

Where arr_input is a variable of type array of string

-Then use a BUILD DATATABLE ACTIVITY and create the single column you want to with column header name and get the output with a variable of type dt1

—then use a FOR EACH activity and pass the above array variable as input and change the type argument as string

—inside the loop use a ADD DATAROW activity and pass the input as item and datatable as dt1

—now this dt1 will have the data which you can write it to a excel with write range activity

@nirmalya.sarkar

1 Like

@Palaniyappan , can you tell me how i set input of add data row ??

Thanks & Regards,
Nirmalya

1 Like

Array row : {item.ToString}

Datatable : dt2

1 Like

Hi
You were almost done
Pass the item to ArrayRow property like this {item.ToString}
Leave the DataRow property empty

And mention the datatable as dt2

Cheers @nirmalya.sarkar

@Palaniyappan ,
I am getting the output only for “Anuj*Patel”. I am sharing my workflow with you. Could you please check and tell me where am I going wrong??
test.xaml (26.3 KB)

Thanks & Regards,
Nirmalya

@nirmalya.sarkar

You can check below reference for your problem

Reference

Hope this may help you

Thanks

@Steven_McKeering , I have gone through it and find it very resourceful. Thank you for sharing this info with me.

Regards,
Nirmalya

1 Like

Thank you @NIVED_NAMBIAR , it worked.

1 Like

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