0

I have array like this below

const spetialCharector = [
                          "http://www.curryconfigurator.org/cc#Quantity", 
                          "http://purl.org/heals/food/Texture",
                          "http://www.curryconfigurator.org/cc#FoodItem",
                          "http://www.w3.org/2001/XMLSchema#float"
                          "http://purl.org/heals/food/hasIngredient"
                          ]

but i want the output like this below

const RemoveSpecialCharectorArray =["Quantity" , "Texture" , "FoodItem" "float" , "hasIngredient"]

Anyone can help me out please if it solved that so much appreciatable

jsBug
  • 348
  • 1
  • 9
  • 1
    That’s the fragment of the URL or, if it doesn’t exist, the last part of the pathname of each URL. `spetialCharector.map((url) => { const url = new `[`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL)`(url); return url.hash.slice(1) || url.pathname.split("/").slice(-1)[0]; });` should get you started. – Sebastian Simon Mar 11 '22 at 07:37

1 Answers1

1

const input = [
          "http://www.curryconfigurator.org/cc#Quantity", 
          "http://purl.org/heals/food/Texture",
          "http://www.curryconfigurator.org/cc#FoodItem",
          "http://www.w3.org/2001/XMLSchema#float",
          "http://purl.org/heals/food/hasIngredient"
          ]
          
let output = input.map((item) => {
  let slashSplit = item.split('/')
  let hashtagSplit = slashSplit[slashSplit.length-1].split('#')
  return hashtagSplit[hashtagSplit.length-1]
  }
 )
  
console.log(output)
timmmmmb
  • 674
  • 7
  • 26