Remove backslash from string

How can we remove backslash from a string.

I have remove the ** from a string.

textStrig.Replace("","") Is not working

@Nithin_P

2 Likes

Is this what you are trying to do ? It works as expected.

image

Regards,
Nithin

2 Likes

yes, but this is not working here, if you know regex we can replace this with any other character

Can you share in a sample input string & the output you are expecting ?

Regards,
Nithin

1 Like

simple bro I have to replace the \ with no space.
Ex. Today is a cool a \ day
Expected Result: Today is a cool a day

Note - Replace is not working here.

@balkishan - you can try with below

  • textStrig.Replace("\"," ")
  • Regex("\{1,}").Replace(textStrig, " ")

image

Works as expected !

Regards,
Nithin

I hope you have not tampered with the Imports & you should be getting the following function defination:

Regards,
Nithin

1 Like

Hey, Here this function will not work because I am storing the data in a DataTable then convert into a string format. So I already checked the method which you mentioned it’s not working.

2nd method is wrong

Hey @Nithin_P & @balkishan

Add .trim to the end of your assign:

Variable1.Replace("\ “,”").Trim

But put the first part with a space. i.e "\ "

I use it all the time and it works for me :slight_smile:

Regards,
MikeB

1 Like

Hi @balkishan

Hope you are doing good
Kindly just mention like this
Str_output = str_input.ToString.Replace.(“\”,””).ToString.Trim

This would work even if the backslash is at front or in middle or atlast of the string
Cheers @balkishan

2 Likes

Hi, Plani I’m doing great bro. Congrats to get the Leader Tag :slight_smile:

I’ve tried but it’s not working. If you see I am using the Extract DataTable the store the whole data in a String Variable using the Output Data Table. But if you see this is not coming in a string. initial text in string and the rest are not. So how can I remove the doube quotes in the middle. because of this this whole text is not in string format. And How can I remove the , “” from the middle. .Replace("","").trim is not working. See the attached snapshot.

@MikeBlades @Lakshman @Palaniyappan

1 Like

Fine
Now do we need to replace double quotes or backslash
And is the value inside the datatable has any double quotes in them

Cheers @balkishan

1 Like

Yes bro, In data table we have comes value with double quotes but when we store the whole value in a string variable using the Output Data Table activity then we have comes with the lot of backslash and this backslash is replacing by the above method. Basically I want to replace this pattern backslash with unique character so that the each line data can be easy untestable.

Hey @balkishan ,

Don’t know if this is what you’re after, but i find if you use multiple " in the replace it counts them as characters, not variable separators:

Variable1.ToString.Replace("\ “”","").Trim

Hopefully this is what you’re after,

Cheers
MikeB

it can be done by replacing like this for doing in json, replace.yourstring(chr(92),"replacement string)