Skip to content

Instantly share code, notes, and snippets.

@johnmurch
Last active October 22, 2020 01:36
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save johnmurch/7f6aac85835ae954c22f63c4bdf645af to your computer and use it in GitHub Desktop.
Save johnmurch/7f6aac85835ae954c22f63c4bdf645af to your computer and use it in GitHub Desktop.
Parse keywords from URL
let url = "https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/";
let kwparse = (url.replace('https://','').replace('http://','').replace('www','').replace('com','').split('-').join().split('/').join().split('.')).join(',').replace(/^,/, '')
let kwuniq = [...new Set(kwparse.split(','))].filter(function(e){return e});
console.log(kwuniq)
// ["amazon", "SanDisk", "128GB", "microSDXC", "Memory", "Adapter", "dp", "B073JYC4XM"]
// Hat Tip - Find a cleaner version at https://gist.github.com/dsottimano/52060e6a43d96804f33c59366c472305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment