Substitute or remove text from a string

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

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

5 Likes

Hi @Ovi,

Edit : Saw now that Darren replied! :man_facepalming:

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

Thank you

3 Likes

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

1 Like

So, I found the solution with
image
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.

@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.

I’m sorry! Check again! : remove a value from a string.mp4 on Vimeo

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

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.

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

image

image

Or maybe some JavaScript!

image

image

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

Use the type template, the fastest solution. :laughing:

So your replacement values are calculated, not static?

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

1 Like

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

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

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.

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

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 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:

3 Likes

Now I believe Telepathy a lot! :muscle: :face_with_peeking_eye:

3 Likes

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