Replies: 2 comments 2 replies
-
这个要回头细看下,尽量以luajit为准,做到向下兼容,毕竟lua 版本以后会一直升,有可能一些语法会一直变动,但是luajit的语法固定了 兼容性更好 回头我会内部适配下 lua 端做内部兼容,适配到luajit 另外尽量走 replace("%",{plain=true}),兼容性更好,也更快,跟是否lua/luajit无关 |
Beta Was this translation helpful? Give feedback.
0 replies
-
测了下,跟参数一没任何关系,lua和luajit的行为一致,都是下面的结果。 xmake> ("foo%%bar"):gsub("%%%%", "_")
< 1: "foo_bar"
< 2: 1
xmake> ("foo%%bar"):gsub("%%", "_")
< 1: "foo__bar"
< 2: 2 其实是第二个参数带有 luaxmake> ("foo%%bar"):gsub("%%", "%")
stdin:1: invalid use of '%' in replacement string
xmake> ("foo%%bar"):gsub("%%", "%%")
< 1: "foo%%bar"
< 2: 2 luajitxmake> ("foo%%bar"):gsub("%%", "%")
< 1: "foobar"
< 2: 2
xmake> ("foo%%bar"):gsub("%%", "%%")
< 1: "foo%%bar"
< 2: 2 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
https://stackoverflow.com/questions/45179381/lua-gsub-replace-with
a:gsub("%%","")
在luajit里面合法,但在lua里面不合法而是要写a:gsub("%%%%", "")
,写的时候以哪一种为准呢Beta Was this translation helpful? Give feedback.
All reactions