I am looking for a way to separate values into key-value pairs before and after a specified delimiter (:) in JavaScript.
For example:
If I search for "product," I want to retrieve the product name and product code as keys, and their respective values (Product 15 and 1234).
var text1=document.documentElement.innerHTML;
var res = text1.match(/Product/g);
for(j=0;j<res.length;j++)
{
console.log(res[j]);
}
<li>Product name: Product 15</li>
<li>product code: 1200</li>
<span> product category : bag </span>