1.匹配字符串中的數字、字母和下劃線
function(w)
table.insert(table,w)
end
end
2.替換字符串中的指定字符
3.判斷字符串中是否有目標字串
4.從文件的絕對路徑中獲取到文件名
if fn_flag then
dest_filename = string.match(filename, ".+//([^//]*%.%w+)$")
end
fn_flag = string.find(filename, "/")
if fn_flag then
dest_filename = string.match(filename, ".+/([^/]*%.%w+)$")
end
5.去掉字符串中括號內的內容,并去掉收尾的空格
newstr = string.gsub(newstr, "^%s*(.-)%s*$", "%1")
print(newstr)---->helloa,ni hao
|
新聞熱點
疑難解答