function aa(n) { //由於下面用正則對字符串進行處理,因此,咱們必須保證n是字符串 var strbefore = n; var strchange; var returnnum; n=n.toString(); var regstr=/[a-zA-Z]{1,}/g; var regnum = /[\d]{1,}/g; n=regstr.exec(n); if(typeof n[0] == 'string'){ strchange = strbefore.substr(n[0].length); return returnnum = regnum.exec(strchange)[0]; }else{ return returnnum = regnum.exec(strbefore)[0]; } // console.log(n[0]); } console.log(aa('abc222ddd'));*/
二、實現extend函數函數