|
楼主 |
发表于 2013-8-19 14:20:15
|
显示全部楼层
本帖最后由 tianheng 于 2013-8-19 02:34 PM 编辑
自己写了个替换函数,无奈不熟悉正则
- function teststr()
- local str = "down,northeast,east,north,south,southeast,out,up";
- print(str);
- print(string.find(str, "out"));
- print(string.gsub(str, "out", "", 1));
-
- print(delstr(str, ",", "out"));
- end
- function delstr(str, p, s)
- local t = utils.split(str, p)
- local r = {}
- for k, v in pairsByKeys(t) do
- if v ~= s then
- table.insert(r, v)
- end
- end
- return table.concat(r, p)
- end
复制代码 结果:
down,northeast,east,north,south,southeast,out,up 28 30
down,northeast,east,north,sh,southeast,out,up 1
down,northeast,east,north,south,southeast,up |
|