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)