var item = {name:"PM2.5"};
item.nameFirst = item.name.replace(/[^a-zA-Z]/g, '');
item.nameLast = /(\d+(\.\d+)?)/.exec(item.name);
if (item.nameLast && item.nameLast.length > 0) {
item.nameLast = item.nameLast[0];
} console.log(item)

javascript正则提取字母和数字小数-LMLPHP

05-26 09:51