Replace comma with quote comma quote in a string

Tried using replace, as well as regex replace. but the string with have blackslashes. The backslashes couldnt be replaced or removed… How do i solve this?

e.g. First,Second,Third
to
“First”,“Second”,“Third”

I added the quotes for the string, but final output has backslashes like
"\"First\",\"Second\",\"Third"

HI @TyraS

Can you share the inputs and the exact output you are trying to extract ??

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi yes ive just edited

Hi @TyraS

So your input is First,Second,Third
And output is “First”,“Second”,“Third”

Right ??

Then may i know from where those slashes comes ??

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Yes…
I use var = var.replace(",", CHR(34).toString+","+CHR(34).toString)
as var = var.replace(",", “”,"") does not work.

Then the output came out with backslashes

Hi @TyraS

I have made one workflow for the same :-
MainPratik.xaml (6.9 KB)

See the output :-

CHR(34).toString+str.Replace(",",""",""")+CHR(34).toString

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

Hi…
It works in the print box. Once i assign to a variable, the backslashes are back.
image

@TyraS I would do it by splitting the string into an array, surrounding each string in the array with quotes, then joining the array back into a single string with a comma delimiter. See the attached workflow as an example:

delete3.xaml (6.9 KB)

Hi @TyraS

I did the same what you said. I am not getting any backslashes

Output :-

image

Workflow for the same :-
MainPratik.xaml (7.4 KB)

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @Pratik_Wavhal @Dave , It doesnt show the backslahes on the message box, but shows on the debugging panel. Hence when i insert the output string into another string, it doesnt work

Hi @TyraS

So you mean to say like the below SS :-

But further what process are you doing on that output value in which you are getting difficulty ??

And what difficulty or Error or the thing that is not working for u bcz of those slashes ??

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Yes those. Im not sure if its because of that that the below code does not work. But it works if i hardcode the string.
Dont work:
dtTable.DefaultView.ToTable(False,str).Clone

Work:
dtTable.DefaultView.ToTable(False,"First", "Second", "Third").Clone

A backslash is never used at any point in the code. Try using a write text activity and saving it to a .txt file. Does it still have backslashes? It may just be a visual issue when you’re looking at it in debug mode

Hi @TyraS

So you are trying to implement below method ??

If Yes then it is just accepting the array and not the string which looks like Array :sweat_smile:

Der is actually much more difference between the actually array variable and the str that looks like array

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Yup!

I see. It does not appear in text file.

Hi @TyraS

Can you try like below just by using my solution in yours :-

dtTable.DefaultView.ToTable(false,strArray).Clone

image

Workflow :-
MainPratik.xaml (8.4 KB)

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@TyraS Since the value is a String, and since you want to Represent each value separated by comma as a Separate value, I guess the Best method would be to use Split()

str = “First,Second,Third”

strArray = Split(str,",")

where strArray should be of the type Array of String

Then you can use it in the Expression as below :
dtTable.DefaultView.ToTable(False,strArray).Clone