|
- string.gsub(str,')','') 报错:invalid pattern capture
- 解决:使用%转义 -> string.gsub(str,'%)','')'%('
-
-
- ministringextend ={}-- 字符串切割function ministringextend.StringSplit( str,reps )local resultStrList ={}
- string.gsub(str,'[^'..reps..']+',function( w )
- table.insert(resultStrList,w)end)return resultStrList
- endfunction ministringextend.EndWith(str_source,str)if#str_source >=#str thenreturn string.sub(str_source,-string.len(str))== str
- elsereturnfalseendendfunction ministringextend.ltrim(input)return string.gsub(input,"^[ \t\n\r]+","")endfunction ministringextend.rtrim(input)return string.gsub(input,"[ \t\n\r]+$","")endfunction ministringextend.trim(input)
- input = string.gsub(input,"^[ \t\n\r]+","")return string.gsub(input,"[ \t\n\r]+$","")end
复制代码 |
|