Open Refine: compare strings within cell, and delete everything after a certain character

Viewed 57

I have a column of values with "//" as the separator between them. For example, one cell might contain - September 17 2021 // September 18 2021.

I want to compare if what comes before and after the separator are the same, and if so, to delete the separator and everything after. Is there are a way to do this in Open Refine? Thanks for your help!

1 Answers

One straighforward way I can think of is splitting the string into an array, remove duplicates and put the string back together. Or to express this in GREL:

value.split(/\s*\/\/\s*/).uniques().join(" // ")
Related