分析lua中的字符串
有人会告诉我,如何从变量中的文本
>Hello World
text,1000
text2,200
读取: 1. line - 如果 in line 是 >并且该行的长度不超过 50 个字符,然后读取,如果不是 - 转到下一行 (此检查的一部分是:
if string.sub(tekst, 1, 1) == '>' then
...
end
但没有检查行的长度。
下一行 - 通过“,”传递文本,并首先从“,”之前获取文本,然后从“,”之后获取文本到不同的变量(以分析它是脚本的另一部分)
我将非常感激
would somebody tell me, how to from text in variable like:
>Hello World
text,1000
text2,200
read:
1. line - if in line is > and line isn't logner than 50 chars then read, if not - go to next line
(part of this checking is:
if string.sub(tekst, 1, 1) == '>' then
...
end
but there is nothing about checking lenght of line.
next lines - impart text by "," and first get text from before "," then get text from after "," to the different vars (to analyse it by another part of script)
I'll be very grateful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您并不完全清楚如何处理匹配的字符串(在 > 和行尾之间),因为
read
是通用的,我只是将其放在表格中。这还取决于字符串中哪些字符代表行结尾。可能性是:
\n
(UNIX、Mac 和其他正常世界)或\r\n
(Windows)Your not entirely clear on what to do with the matched string (between > and the end of the line), as
read
is kind of generic, I just put it in a table.This depends also on which character(s) represent a line ending in the string. possibilities are:
\n
(UNIX, Mac, and the rest of the sane world) or\r\n
(Windows)