
FileStream fs = new FileStream("d:\\atxt", FileModeOpen); StreamReader m_streamReader = new StreamReader(fs); m_streamReaderBaseStreamSeek(0, SeekOriginBegin); string arry = ""; string strLine = m_streamReaderReadLine(); do { string[] split = strLineSplit('='); string a = split[0]; if (aToLower() == "ip") { arry += strLine + "\n"; } strLine = m_streamReaderReadLine(); } while (strLine != null && strLine != ""); m_streamReaderClose(); m_streamReaderDispose(); fsClose(); fsDispose(); ConsoleWrite(arry); ConsoleReadLine(); 如果你要大小写也要匹配的话把ToLower() 去掉就行了
local cjson = require("cjson");
local file = ioopen(path,"r")
local json = file:read("a")
file:close()
youWantJson = cjsondecode(json)
关于你这个问题我不是很确定你到底是想问怎么匹配出字符串里的路径还是想做windows的路径相关的 *** 作
如果是路径相关 *** 作的话 看以下内容
lua本身不会自带这个相关功能
所以功能一般在库里
如果你有装luaforwindows的话 你可以找一下这个路径下的
C:\Program Files\Lua\51\clibs\lfsdll
具体案例参考
C:\Program Files\Lua\51\examples\luadoc\lfsluadoc
----------------------------------------------
如果只是想匹配出路径的话
print(stringmatch("c:\\file\\atxt",("(-)a%txt")))
ostime()返回当前的时间的time stamp,两次求差获得差值即可\x0d\至于把描述转换成小时,标准库没有提供,自己除余换算了只有\x0d\s1 = ostime()\x0d\\x0d\---\x0d\s2 = ostime()\x0d\s = osdifftime(s2, s1)\x0d\stringformat("%2d:%2d:%2d", s/(6060), s/60%60, s%60)
程序仅针对全角的汉字进行“串相与” *** 作(取最大相同串),供参考。
==============================================================
a="和水果混合肌肤"
b="水果,喜欢,回收"
al=#a
bl=#b
len=mathmin(al,bl)
bool=false
s=''
for i=len,0,-2 do
for j=1,al-i+2,2 do
s1=stringsub(a,j,j+i+1)
for k=1,bl-i+2,2 do
s2=stringsub(b,k,k+i+1)
if s1==s2 then
s=s2
bool=true
break
end
end
if bool then break end
end
if bool then break end
end
print(s)
以上就是关于lua的io,读取文件,匹配关键字,获取内容下面内容.并返回全部的内容,包括:lua的io,读取文件,匹配关键字,获取内容下面内容.并返回、用lua语言访问一个URL,然后获取到相应的json数据、怎么用lua获取文件路径等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)