How does the JS regular outlook match a number without a percent sign?

I am practicing regular foresight. I would like to ask the old driver to take a look at this:

var names = "18180cm82.5%A";

// A: % 
names.match(/[\d\.]+(?=%)/g); // ["82.5"]

// B: %  18180
names.match(/([\d\.])+(?!%)/g); // ["18", "180", "82."]
here I would like to ask, in the case of exercise B, how to write rules to successfully match 18 and 180, can you do that?
Thank you for the old driver"s help

/ ([d] + d) (?!%) / g try it


try this names.match (/ ([\ d] +) (?! [\ d.^%]) / g)

clipboard.png

Menu