我需要一些帮助来创建我的模式。我已经完成了基本部分,但仍然存在一个问题。
假设我有一个字符串如下:
John: I can type in :red:colour! :white:Not in the same :red:wo:green:rd :white:though :(
我有这个代码设置来将颜色与实际值分开:
line = "John: I can type in :red:colour! :white:Not in the same :red:wo:green:rd :white:though :("
for token in string.gmatch(line, "%s?[(%S)]+[^.]?") do
for startpos, token2, endpos in string.gmatch(token, "()(%b::)()") do
print(token2)
token = string.gsub(token, token2, "")
end
print(token)
end
将输出:
John:
I
can
type
in
:red:
colour!
:white:
Not
in
the
same
:red:
:green:
word
:white:
though
:(
当我希望它打印出来时:
John:
I
can
type
in
:red:
colour!
:white:
Not
in
the
same
:red:
wo
:green:
rd
:white:
though
:(
任何帮助将不胜感激。