let str = readline(); function getStr(str){ let res; let returnStr; let resArr = []; if(/[^a-zA-Z\s]/g.test(str)){ throw new Error('输入值错误'); } let reg = /(\s+)?([a-zA-Z]+)/gi; returnStr = str.match(reg); for(let i = returnStr.length - 1; i>=0; i--){ resArr.push(returnStr[i].split('').reverse().join('')) } console.log(resArr.join('')); } getStr(str);