문자와 숫자, 소수의 자바 스크립트 정규 추출물

var에 항목 = {이름 : "PM2.5" }; 
item.nameFirst = item.name.replace (/ [^ A-ZA-Z] / g '' ); 
item.nameLast = /(\d+(\.\d+)?)/ .exec (item.name);
경우 (item.nameLast && item.nameLast.length> 0 ) { 
    item.nameLast = item.nameLast [0 ]; 
} 

을 console.log (항목)

 

추천

출처www.cnblogs.com/yeminglong/p/11635385.html