419
Views
7
Comments
Solved
Replacing backslash - single quote " \" " with empty single quotes" " "

Hi All,

I have a scenario where I need to replace replace " \" " to " " ". I am trying to use the replace function but how to do it here.

I could have just use replace (string,"\", "") but is there are data where I will be getting "\" in that data which I don't want to replace.

I am open to any other approach if possible. 


Thanks and Regards

Pranav 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

In addition, in OutSystems, if you want a single (that is, one) double quote inside a Text, you acually type two. So to replace \" by ", you use

Replace(MyText, "\""", """")


2022-02-07 08-52-30
Pranav Pandey

Kilian Hekhuis wrote:

In addition, in OutSystems, if you want a single (that is, one) double quote inside a Text, you acually type two. So to replace \" by ", you use

Replace(MyText, "\""", """")



Thanks !!

It worked, actually, I was looking for ways to do the same, looks like I was missing a "  :)

2025-08-22 10-19-44
Pramod Jain
 
MVP

Hi Pandey Ji,

You said that you want to replace "\" "  to " " " and than you said there is some data you dont want to replace it . Could you please elaborate your use case a little more so that i can look for solution.

Any example will be great !

Regards,

-PJ-

2022-02-07 08-52-30
Pranav Pandey

Hi Pramod,

Please see the sample data below

"{""load"":""{\""row1\"":{\""col1\"":\""99978444P\"",\""col2\"":\""99978444P\"",\""col3\"":\""99978444P\"",\""pascodeid\"":\""n\VOL3PL-TK2nh\ZXjXN5QV*6RM""}"

We have a column named passcodeid . It consist of value that can have special characters like \ .- ,* in it.

I don't want to remove it.


Thanks

2020-09-21 08-42-47
Vincent Koning

So you trying to get valid JSON or is there some other use case?

2020-09-21 08-42-47
Vincent Koning

To get valid JSON from you example use the following;

Use the following replace rules;

  1. \"" to "
  2. "" to "
  3. "{ to {
  4. }" to }

You example is missing 2 } at the very end of the json. If you follow these rules in this order and then add the 2} you should get valid json. It's is possible that your parser will nag about the invalid escapes in the pascodeid field though, that's not really up to spec.

Good luck,

Vincent

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

In addition, in OutSystems, if you want a single (that is, one) double quote inside a Text, you acually type two. So to replace \" by ", you use

Replace(MyText, "\""", """")


2022-02-07 08-52-30
Pranav Pandey

Kilian Hekhuis wrote:

In addition, in OutSystems, if you want a single (that is, one) double quote inside a Text, you acually type two. So to replace \" by ", you use

Replace(MyText, "\""", """")



Thanks !!

It worked, actually, I was looking for ways to do the same, looks like I was missing a "  :)

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

You're welcome :). It's one of those things you just need to know :). Happy coding!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.