Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #extract #dynamic #variable #bracket #javascript
ADD COMMENT
Topic
Name
2+1 =