对称匹配运用实例
By
netfox
at 2020-10-23 • 1人收藏 • 1109人看过
import console; console.setTitle("对称匹配运用") var err = ` {Error}: {Line}:#188 {File}:K:\runing\application\controllers\index.aardio {Error}: {Expected}:'=' {Near}:'if'`; console.log(err+'\n\n***************************\n***** 格式美化 译中文 *****\n***************************\n'); prettifyError = function(errSource){ var err,formatErr = {},""; var fanyi = {Line="行号";File="文件";Expected="预期";Near="靠近"}; for(key in string.gmatch(errSource,"%{}")) table.push(err,key); for(i=1;#err){ if err[i] = "{Error}" continue; pattern = i = #err ? string.concat(err[i],"[^:](.*?)$") : string.concat(err[i],"\:(.*?)",err[i+1]); errValue = tostring(string.match(errSource,pattern )); var key = string.trim(err[i],"{}"); formatErr += string.concat(string.replace(key,key,fanyi[key]),": ",errValue,'\r\n'); } return formatErr; } console.log(prettifyError(err)); console.pause(true);
登录后方可回帖