如前所述,我对lua相对较新,但同样,我学得很快.我最后一次在这里得到了帮助,这对我帮助很大,而且我能写出更好的剧本.现在我来到另一个问题,我认为这将使我的生活更轻松一些.我不知
winds = string.gsub(winds,"%b<>","") winds = string.gsub(winds,"%c"," ") winds = string.gsub(winds," "," ") winds = string.gsub(winds," "," ") winds = string.gsub(winds,"^%s*(.-)%s*$", "%1)") winds = string.gsub(winds," ","") winds = string.gsub(winds,"/ ", "(")
玩笑
把它变成一个函数是很容易的部分.function stripdown(winds) winds = string.gsub(winds,"%b<>","") winds = string.gsub(winds,"%c"," ") winds = string.gsub(winds," "," ") winds = string.gsub(winds," "," ") winds = string.gsub(winds,"^%s*(.-)%s*$", "%1)") winds = string.gsub(winds," ","") winds = string.gsub(winds,"/ ", "(") return winds end
写入的这个函数确实产生并放弃了很多中间字符串结果,这可能是一个相对昂贵的操作.几乎可以肯定值得仔细研究string.gsub()及其pattern language的文档.应该可以在较少的操作中至少完成一些您指定的内容.