# Substitute or remove text from a string

**URL:** https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009
**Category:** Ask for Help
**Created:** [August 5, 2022, 11:53am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009 "2022-08-05T11:53:43Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Ovi](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@Ovi](https://community.glideapps.com/u/Ovi)
#### Post date: [August 5, 2022, 11:53am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/1 "2022-08-05T11:53:43Z")

</div>

Let’s say I have this string :  
a,b,c,d  
How can I remove “,c” from the string in a Glidetable column ?

---

<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: [August 5, 2022, 12:08pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/2 "2022-08-05T12:08:01Z")

</div>

You can do that with a template column. You just use your string as the source and replace `,c` with nothing.

---

<div class="post-metadata">

### Author: ![Dilon\_Perera](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/dilon_perera/32/85652_2.png) [@Dilon\_Perera](https://community.glideapps.com/u/Dilon_Perera)
#### Post date: [August 5, 2022, 12:09pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/3 "2022-08-05T12:09:16Z")

</div>

Hi @Ovi,

**Edit : Saw now that Darren replied! 🤦‍♂️**

If it’s not changing and only **,c** then you can use a Template column. - **like Darren mentioned!**

If it should be dynamic you can do something like this : [remove a value from a string.mp4 - Google Drive](https://drive.google.com/file/d/1SGCzEXLUnrGyLq-YFJKUsNF-CCh3KaXR/view?usp=sharing)

Thank you

---

<div class="post-metadata">

### Author: ![Ovi](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@Ovi](https://community.glideapps.com/u/Ovi)
#### Post date: [August 5, 2022, 1:02pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/4 "2022-08-05T13:02:51Z")

</div>

Thanks … I’m waiting for the video to be displayed in Drive … @Darren_Murphy , the template is not working for me as both the string and the replacement text are found in columns and from what I see in the template option you need te mention by text what to replace … if it will be the other way around, it will solve the problem because I need to look in Column 1 to find the text from Column 2 and replace it with nothing in Column 1

---

<div class="post-metadata">

### Author: ![Ovi](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@Ovi](https://community.glideapps.com/u/Ovi)
#### Post date: [August 5, 2022, 1:29pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/5 "2022-08-05T13:29:32Z")

</div>

So, I found the solution with  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/5/c5089a7ee649916966732091821b3496ea07406d.png)  
if anyone is looking for this.

But I have another question  
Is there a way to remove some custom things let’s say in Column 1 I have a string that can be like this :  
,feqsefw - starting with a comma  
or  
sdsgsg, - ending with a comma  
or  
dsfsdgf,dfssqgq - 2 commas

Is there a way to search for those situations , even with an excel formula and remove the comma from the front, from the end or from those 2 and have only 1 ?

Thanks.

---

<div class="post-metadata">

### Author: ![Ovi](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@Ovi](https://community.glideapps.com/u/Ovi)
#### Post date: [August 5, 2022, 1:30pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/6 "2022-08-05T13:30:48Z")

</div>

@Dilon_Perera the video is still processing … in the future it will be awesome if you can use something like Loom or a screenshot …makes it easier and faster … but I appreciate the involvement … Thank you.

---

<div class="post-metadata">

### Author: ![Dilon\_Perera](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/dilon_perera/32/85652_2.png) [@Dilon\_Perera](https://community.glideapps.com/u/Dilon_Perera)
#### Post date: [August 5, 2022, 1:48pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/7 "2022-08-05T13:48:37Z")

</div>

I’m sorry! Check again! : [remove a value from a string.mp4 on Vimeo](https://vimeo.com/736864721)

---

<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: [August 5, 2022, 1:49pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/8 "2022-08-05T13:49:51Z")

</div>

> [@Ovi](#):
>
> the template is not working for me

A template works fine based on how you originally posed the question 😉

> [@Ovi](#):
>
> Is there a way to remove some custom things let’s say in Column 1 I have a string that can be like this :  
> ,feqsefw - starting with a comma  
> or  
> sdsgsg, - ending with a comma  
> or  
> dsfsdgf,dfssqgq - 2 commas

This is not clear to me. For each of the above three cases, what would the expected result be?  
By the way, I only see one comma in your 3rd example.

---

<div class="post-metadata">

### Author: ![Dilon\_Perera](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/dilon_perera/32/85652_2.png) [@Dilon\_Perera](https://community.glideapps.com/u/Dilon_Perera)
#### Post date: [August 5, 2022, 1:53pm UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/9 "2022-08-05T13:53:13Z")

</div>

> [@Ovi](#):
>
> But I have another question  
> Is there a way to remove some custom things let’s say in Column 1 I have a string that can be like this :  
> ,feqsefw - starting with a comma  
> or  
> sdsgsg, - ending with a comma  
> or  
> dsfsdgf,dfssqgq - 2 commas
> 
> Is there a way to search for those situations , even with an excel formula and remove the comma from the front, from the end or from those 2 and have only 1 ?
> 
> Thanks.

I think the easiest way would be using a Split text column and a Joint text column!

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/0/604562c5ce9853bf96d27545aa47d8bbb8ea837c.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/f/9f263cd27d53ec0a792b0f0da5f6ea00e87d621b.png)

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

Or maybe some JavaScript!

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

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/9/59406193298e13b410f5dce7d1e82e15bbcf350a.png)

> **JS**
>
> ```auto
> var string = p1;
> return string.replace(/^[,\s]+|[,\s]+$/g, '').replace(/,[,\s]*,/g, ',');
> 
> ```

---

<div class="post-metadata">

### Author: ![resepsionis\_ganteng](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/resepsionis_ganteng/32/39081_2.png) [@resepsionis\_ganteng](https://community.glideapps.com/u/resepsionis_ganteng)
#### Post date: [August 6, 2022, 1:18am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/10 "2022-08-06T01:18:50Z")

</div>

# Use the type template, the fastest solution. 😆

 ![remove string](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/b/3ba6feee0b368d6d4403f2b51fbbcd923223a586.png)

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [August 6, 2022, 1:23am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/11 "2022-08-06T01:23:08Z")

</div>

> [@Ovi](#):
>
> the template is not working for me as both the string and the replacement text are found in columns and from what I see in the template option

So your replacement values are calculated, not static?

Can you explain further about what you’re trying to do?

---

<div class="post-metadata">

### Author: ![Ovi](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@Ovi](https://community.glideapps.com/u/Ovi)
#### Post date: [August 6, 2022, 3:54am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/12 "2022-08-06T03:54:13Z")

</div>

> [@Darren\_Murphy](#):
>
> A template works fine based

I use it in a lot of columns but for what I wanted to achieve here it didn’t work, but the solution I posted worked like a charm … could be the question but anyway … we have 2 solutions now :))

Thanks

> [@Darren\_Murphy](#):
>
> This is not clear to me. For each of the above three cases, what would the expected result be?  
> By the way, I only see one comma in your 3rd example.

It has 2 commas but they aren’t displayed … don’t know why 🙄

So, in Col1 I have a string that I wanted to be removed from a list of strings in Col2 separated by commas, and also to remove the comma if the value from Col1 is in Col2 with a comma in front.

After picking my brain I ended up with this solution:  
I creat an array from Col 2 in Col 3 , I check the value from Col1 in Col3 and get the index, I create another Col4 with the value in Col1 with a comma in front and this action  
If Value from Col1 is in Co3 with an index \>=1 then I remove the value that is in Col4 , if the index is 0 that means it’s just the first value and I remove it without a comma in front , which means the original value from Col1.

Hope it makes sense for all, but it worked for me.

---

<div class="post-metadata">

### Author: ![Ovi](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@Ovi](https://community.glideapps.com/u/Ovi)
#### Post date: [August 6, 2022, 3:56am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/13 "2022-08-06T03:56:50Z")

</div>

@Dilon_Perera that’s actually a great way to do it … and similar to what I achieved … Thank you.

---

<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: [August 6, 2022, 4:08am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/14 "2022-08-06T04:08:37Z")

</div>

> [@Ovi](#):
>
> So, in Col1 I have a string that I wanted to be removed from a list of strings in Col2 separated by commas, and also to remove the comma if the value from Col1 is in Col2 with a comma in front.

Okay.  
I haven’t looked at what Dilon did, but based on that description I would probably just create an array from the first column (using Split text), and then use the [Remove Element from Array](https://www.glideapps.com/plugins/remove-from) plugin to remove the string. This would return an array, so a joined list column would then be needed to convert it back into a list.

So something like this:

 ![Screen Shot 2022-08-06 at 12.07.15 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/0/90ef25d6bafc048d91e1e48669cda1b81364a82b.png)

---

<div class="post-metadata">

### Author: ![Dilon\_Perera](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/dilon_perera/32/85652_2.png) [@Dilon\_Perera](https://community.glideapps.com/u/Dilon_Perera)
#### Post date: [August 6, 2022, 6:22am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/15 "2022-08-06T06:22:57Z")

</div>

Now I believe Telepathy a lot! 💪 🫣

---

<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: [August 7, 2022, 6:23am UTC](https://community.glideapps.com/t/substitute-or-remove-text-from-a-string/46009/16 "2022-08-07T06:23:30Z")

</div>

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