Answers for "How to extract dynamic variable from <> bracket in javascript"

0

How to extract dynamic variable from <> bracket in javascript

let pattern = "/used-cars/<city_name>/<location>/<car_name>-cars-for-sale"
let matches = pattern.match(/<.+?>/g);
const newArray = matches.map((match) => match.replace(/[<>]/g, ''));
let object = {};
newArray.map((item, index) => {
  object[item] = '';
});
console.log(object)
Posted by: Guest on August-26-2021

Code answers related to "How to extract dynamic variable from <> bracket in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language