# Looking for 1 column to escape characters

**URL:** <https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683>\
**Category:** Ask for Help\
**Created:** [November 6, 2024, 8:21pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683 "2024-11-06T20:21:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeartwoodTreeCo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/heartwoodtreeco/32/8150_2.png) [@HeartwoodTreeCo](https://community.glideapps.com/u/HeartwoodTreeCo)\
**Post date:** [November 6, 2024, 8:21pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/1 "2024-11-06T20:21:54Z")

</div>

I’m using Glide API to archive rows. I’d like to escape out all the offending characters with one JavaScript column instead of multiple Replace all columns, and I’m not very experienced with JavaScript yet.

For example, this little snippet that I got from a free AI tool 🫢

```auto
{
       return p1.replace(/\\/g, '\\\\') 
                      .replace(/"/g, '\\"')  
                      .replace(/\f/g, '\\f') 
                      .replace(/\n/g, '\\n') 
                      .replace(/\r/g, '\\r') 
                      .replace(/\t/g, '\\t'); 
}

```

does well at escaping, but converts some strings to dates which is not very helpful

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/8/68c13cf4553c60a036645576b3bd356f0c200e7a.png)

What’s the simplest way to do this?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 6, 2024, 8:41pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/2 "2024-11-06T20:41:49Z")

</div>

So that’s just a regular text column and a javascript column?

---

<div class="post-metadata">

**Author:** ![HeartwoodTreeCo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/heartwoodtreeco/32/8150_2.png) [@HeartwoodTreeCo](https://community.glideapps.com/u/HeartwoodTreeCo)\
**Post date:** [November 6, 2024, 8:56pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/3 "2024-11-06T20:56:01Z")

</div>

Yes - the javascript column on the right is producing the dates from “job 1” and “job 4”

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 6, 2024, 9:18pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/4 "2024-11-06T21:18:38Z")

</div>

That’s weird. I can’t reproduce your issue. I don’t know if there are other hidden characters that I’m missing, or my device is just handling it differently.

Not sure if this will work, but try this once.

```auto
{
    return p1.replace(/\\/g, '\\\\')
             .replace(/"/g, '\\"')
             .replace(/\f/g, '\\f')
             .replace(/\n/g, '\\n')
             .replace(/\r/g, '\\r')
             .replace(/\t/g, '\\t')
             .toString();
}

```

---

<div class="post-metadata">

**Author:** ![HeartwoodTreeCo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/heartwoodtreeco/32/8150_2.png) [@HeartwoodTreeCo](https://community.glideapps.com/u/HeartwoodTreeCo)\
**Post date:** [November 6, 2024, 10:14pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/5 "2024-11-06T22:14:15Z")

</div>

It returns the same results. I keep seeing this error in the JS columns, even when I create a new column, even before pasting in the code.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/b/cb62b83d17c3f922a41f55b8554433c997a08d67.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 6, 2024, 11:10pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/6 "2024-11-06T23:10:25Z")

</div>

I’ll try playing around some more, but since I can’t reproduce, I don’t know if I’ll have an answer for you. If anything, you could try a different browser or computer to see if a different javascript engine makes a difference.

I don’t typically worry much about the warnings. They are just warnings, and many times due to one row that may have an empty or unexpected value. If they get in the way, then I’ll usually put it a Try/Catch to catch any errors and bow out gracefully. But I think Glide already does that and that’s why it only shows as a warning.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 7, 2024, 8:58am UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/7 "2024-11-07T08:58:40Z")

</div>

> [@HeartwoodTreeCo](#):
>
> I’m using Glide API to archive rows. I’d like to escape out all the offending characters with one JavaScript column instead of multiple Replace all columns,

I would take a step back here and look at the bigger picture.  
When you talk about “offending” characters, I’m guessing that you are referring to characters that result in broken JSON when the JSON is constructed using a template?

If that’s the case, what you should be doing is using the JSON Object and/or JSON Template columns to construct your JSON. Using these columns will ensure that you always get valid JSON, without having to resort to any JavaScript gymnastics.

---

<div class="post-metadata">

**Author:** ![HeartwoodTreeCo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/heartwoodtreeco/32/8150_2.png) [@HeartwoodTreeCo](https://community.glideapps.com/u/HeartwoodTreeCo)\
**Post date:** [November 8, 2024, 2:43pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/8 "2024-11-08T14:43:47Z")

</div>

Thanks for the push to try those columns. After some trial and error, I got the JSON Template column to do the job. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [November 15, 2024, 2:44pm UTC](https://community.glideapps.com/t/looking-for-1-column-to-escape-characters/77683/9 "2024-11-15T14:44:07Z")

</div>

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