Remove text from array items

I don’t know if this is possible, but I’ve hit a wall and can’t figure something out.

I have an split text column that is made up of a unique value and then two pieces of text (3 columns that are combined using a template column, with items separated by “|”). The result is something like “Unique|abc|def , Unique|ghi|xyz”. This array can have multiple elements, each one beginning with “Unique”.

I’m looking to remove my “unique” text from each of the elements in the array so that my new array is just “abc|def, ghi|xyz”

Any help is appreciated!

Have a look at the array splice plugin

1 Like

I tried that, but I think my issue is that I need to modify the individual items that make up the elements of the array, not the actual elements themselves. Apologies, I’m probably not using correct terminology.

I think I need to use a text plugin to remove the first section of my text column — the first “element” of each 1|2|3 item to get a result of 2|3 to be used in my array.

Here are some screenshots:

Split Text Array (created from a choice component with multiple selection):

The new array should remove the “100409…” unique value and only contain the "January|2022, April|2022, etc).

Alternatively, I may have just discovered why @Robert_Petitto wants to have the left side of the template column configurable… If I could configure the “Unique value” to be replaced with nothing/blank, I think that would easily remove it from my array in a really simple process.

1 Like

Okay.
Extract Matching Text will do that. I’m away from my computer at the moment, but the regex you’ll need should be something like:

^.*|(.*)
1 Like

I don’t know much about Regular Expressions… but in my mind this should work (but results in absolutely nothing!).

I have my unique value as a column… I add a template column that adds ^ to the beginning and “$” to the end of it. I use that as my Regular Expression in the “Extract Multiple Matching Texts” column… I would think that this should remove the Unique value from the text column… but it doesn’t.

Oh wow good timing haha… I’ll try that expression.

Edit… not giving me any result. I tried with both the Extract Text and Extract Multiple Text columns. My “Text” is the comma-separated list of items (each comprised of two “|” ) and then I pasted in your expression as the regular expression.

meh… you got me out of bed :stuck_out_tongue:

Use the Extract Multiple Matching Text plugin

^.+\|(.+)\|(.+)$

1 Like

Haha sorry! This got me somewhere… but it only results in the last item in the array being displayed (as opposed to each element that used to contain the unique string).

Screenshot shows it “found” September 2022 as two separate elements, but didn’t find “February 2022”, which was another item in my comma-separated list.

Can you give me a single line of data that I can copy/paste?

698ff6f8-1970-47a9-b2f6-05b606f2c372|February|2022,698ff6f8-1970-47a9-b2f6-05b606f2c372|June|2022,698ff6f8-1970-47a9-b2f6-05b606f2c372|September|2022

oh, right. I see…

Okay, gimme a few minutes.

1 Like

Is this the result you need?

No, I was hoping for “February|2022,June|2022,September|2022” … basically just removing “698ff6f8-1970-47a9-b2f6-05b606f2c372” from the entire line of text each time it appears.

I have that “698ff6f8-1970-47a9-b2f6-05b606f2c372” as a separate column too… so I thought I could use it as my text to extract… something like
image
where I replace UNIQUE with my “698ff6f8-1970-47a9-b2f6-05b606f2c372”.

That’s just an extra joined list column to put them back together.

  • Split Test column
  • Single Value column, taking the first value
  • Remove element from array, removing the first item from the split text array
  • Joined list

oh, wait… the key appears multiple times… duh
okay…

1 Like

If it’s too wild, I think I can restructure so that my initial data is captured differently and then my unique value gets added to it afterwards…

I think I’ve created a work-around where I first pull in my Month|Year and then I use a template to add the Unique value… then create the joined/split lists from there. It’s working backwards, but I end up with the data I need… I think! Haha

Appreciate the help!

If you don’t mind a bit of JavaScript…

var re = new RegExp(p2, "g");
return p1.replace(re, "");

3 Likes

This is pretty sweet! Thanks!

1 Like

So I can go back to bed now? :thinking:

2 Likes

Haha please do!

1 Like

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