Replacements

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Replacements

Hugo <Nabble>
Consider this code (Lua book, page 185):
t = { status='up', name='Server' }
s = "$name is $status, isn't it?"
print(string.gsub(s, "$(%w+)", t))
In standard Lua we get:
Server is up, isn't it?	2
In Luan we get:
$name is $status, isn't it?	0
Why?
Reply | Threaded
Open this post in threaded view
|

Re: Replacements

fschmidt
Administrator
There was a bug that I fixed in rev 88.  But you still need to use Java regex (which is uglier) like this:
t = { status='up', name='Server' }
s = "$name is $status, isn't it?"
print(string.gsub(s, "\\$(\\w+)", t))
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Replacements

Hugo <Nabble>
It works fine. The java regex is not a problem. Closing thread.