Ultimately what I'm trying to do here is match a string against a list of regular expressions and have a second list of strings to substitute.
I've tried a bunch of things now, and I just can't seem to get it to work properly.
Though, this seems to indicate I'm doing it correctly: http://math2.org/luasearch/rex.html#rex_gsub
function process_name (room_name)
-- long regular expressions [ordered]
reName = {"^(A|An) (somewhat |very |very very |extremely )?(small |large )?cave$",
"^(A|An) (somewhat |very |very very |extremely )?(small |large )?cavern$",
"^(A|An) (somewhat |very |very very |extremely )?(small |large )?tunnel$"}
-- short strings [ordered]
sName = {"A cave",
"A cavern",
"A tunnel"}
--Convert matched long regular expressions to corresponding short strings
for i,item in ipairs(reName) do
room_name = rex.gsub(room_name, item, sName[i])
end
return roon_nameI've tried a bunch of things now, and I just can't seem to get it to work properly.
Though, this seems to indicate I'm doing it correctly: http://math2.org/luasearch/rex.html#rex_gsub