I have the following string that I am trying to match with RegEx:
286,879 in Home & Kitchen (See Top 100 in Home & Kitchen)
339 in Cardboard Cutouts
2,945 in Jigsaws (Toys & Games)
This is my code/regex:
const matches = text.matchAll(/(?<!Top )([\d,|]+) in[\s\n ]([\w&'\s]+)/g);
for(const match of matches){
const rank = parseInt(match[1].replace(/[^\d]/g, ''));
const category = match[2].trim()
console.log(`${category} = ${rank}`)
}
However, the the only parts it should match on are: 286,879 in Home & Kitchen, 339 in Cardboard Cutouts, 2,945 in Jigsaws (Toys & Games)
The expected output should be:
Home & Kitchen = 286879
Cardboard Cutouts = 339
Jigsaws = 2945
How can I adjust the regex to ignore the 100 in Home & Kitchen string
Thanks