How to scan for duplicates in a URL?

Hi guys,

First of all, I’m happy to be here and I would love to get your help with a method I want to develop.
I’ll try to explain myself as clear as I can so you could understand my needs and help.

We’re using a LinkedIn search URLs on a daily basis. Most of them contains many strings and terms in order to filter our target audience. For example:

*(Lead OR Architect OR Director OR SVP OR EVP OR Vice OR Chief OR VP OR Head) AND Data AND (Engineering OR “Application Development” OR “Software Development”) AND NOT (Expert OR Technician OR Support OR Maintenance OR QA OR quality OR Customer OR Specialist OR student *

And here’s a part of the URL for example:


Basically, we have a lot of duplicates on this links, and I want to reduce this problem in order to optimize our search, targeting and of course to create space for different filters. (space is limited).

So, I’ve created a new workspace on AirTable for this task.
I want to use a script/method/app to spot all the duplicates on the above chain, remove them and create the output on a different column.

So the script needs to flag and remove these duplicates automatically, and reconstruct a clean chain.

Perhaps the way to do this is to break the link into Cells and regroup it into a chain.

The chain has the following logics

  1. SpaceORSpace between every keyword
  2. Quotes " " compile 2 or more keywords into one. For exmaple “Thank you” will go into a cell of its own.
  3. Partneasis () to use AND/OR for conditions.

Any idea to solve this problem would be very helpful. Thanks for your attention!

Hi @Mr_Kav, and welcome to the community!

Please point out an example of a “duplicate” in the above example. Also, please define a “clean chain”.

@Bill.French Thanks for your response!

I’ve pasted only a partial chain so the post will be user friendly.
Here’s the full chain:

(Lead OR Architect OR Director OR SVP OR EVP OR Vice OR Chief OR VP OR Head) AND Data AND (Engineering OR “Application Development” OR “Software Development”) AND NOT (Expert OR Technician OR Support OR Maintenance OR QA OR quality OR Customer OR Specialist OR student OR owner OR media OR founder OR Consultant OR Adviser OR Consulting OR Consultancy OR Advisory OR Board OR professor OR intern OR assistant OR junior OR JR OR office OR ceo OR “co-founder” OR graduate OR undergrad OR contractor OR “Chief Executive” OR advisor OR entry OR journalist OR writer OR secretary OR trainee OR recruit OR novice OR adviser OR author OR freshman OR Undergraduate OR postgraduate OR Sales OR coed OR cofounder OR council OR partner OR advisor OR Project OR Projects OR District OR Regional OR HR OR Human OR Analyst OR Freelance OR Freelancer OR Editor OR Associate OR Supervisor OR Analyst OR Prep OR Account OR Accounting OR Accounts OR Crime OR solutions OR Services OR Solution OR “Data Center” OR Datacenter OR Azure OR GCP OR Science OR Azure OR portfolio OR field OR Mechanical OR Electric OR Electronic OR Controls OR Structure OR clinical)

You can see Analyst and Azure appear twice in this chain

“Clean chain” - meaning new cell with the same chain minus duplicates

Thanks so much for your help!

Yep - I see that, and isn’t it possible (in some “chains”) that such duplications are required depending upon the entire context of the boolean query? If so, how will such streamlining logic be able to understand the intent of the query-writer?

If there are indeed cases where fields need to be used multiple times to construct the intended query, whatever algorithm you create to optimize the length of the query must deconstruct the entire query to be sure it doesn’t thwart the original intent.

Certainly, this example demonstrates cases where additional mentions of Azure serve no purpose and may be eliminated. And such optimization is certainly possible through a script transformation. However, I would be more interested in fixing this at the source. One must ask -

What tool created this sub-optimized query in the first place? And can it be modified to produce “clean chains”?

One Approach…

To do this with precision probably requires a regular expression in javascript like this. This is supported in Script blocks and Action scripts. It might be possible in a formula, but that would make it extremely difficult to achieve without knowing the repeating tokens in advance. Ideally, you want an algorithm that works when unanticipated [duplicate] patterns emerge.

@Bill.French, Thanks again for your attention

Actually there isn’t a case in which I’ll need the same expression to appear twice. This query built to include/exclude titles.
We can have similar words like “Engineer” and “Engineering” or “Project” and “Projects”, but nothing identical.
The reason that we have duplicates in it in the first place, is that too many users have access to this query, and each one of them add/remove titles. That’s why we ended up with a lot of expressions and duplicates.

The current situation require us to go over the whole chain, spot duplicates and remove them.
So I looked into a solution in which I could filter these duplicate and print the new output “ready to use”.

If I’m going macro here, this is a part of the new base we’re building right now. I want to create a campaign builder, so our users will insert the relevant field and get the final outcome. Their next action will be copy and paste on the website and initiate the campaign search link.

I’ve looked into your solution and tried to implement it using this app, but it doesn’t recognize JS.
Also, I need to figure out how to exclude terms like ),(, OR,". They appear multiple times but these are syntax terms and can’t be removed.
Can you give an example using this script and the above chain?

One last thing, if this thing is too complicated, I thought maybe I can use Vlookup and print only the duplicates so I’ll know what to remove. Honestly, I prefer the first method so it’ll be “plug & play” without the need to edit it, but if there’s no solution - I’ll take that.

Thanks so much for your time, I really appreciate it.

Sure. Imagine a string with these duplicate queries:

let queryString = "... OR Analyst OR Freelance OR Freelancer OR Editor OR Associate OR Supervisor OR Analyst OR Prep ...";

The way to remove all the dupes would go something like this:

newQuery = queryString.replace(/\\b(\\w+)(?:\\W+\\1\\b)+/ig, "").replace(/ OR OR /ig, " OR ");

The first replace() eliminates the second, third, n… duplicates. The second replace() eliminates the vacancies left between the ORs.

Without an understanding of the app and how it crafts these suboptimal queries, I can’t really advise.

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