我有类似的东西
str = "What a wonderful string //011// this is"
我必须用类似的//011//东西替换convertToRoman(011)然后得到
str = "What a wonderful string XI this is"
但是,这里转换成罗马数字是没有问题的。字符串也可能str没有//...//. 在这种情况下,它应该简单地返回相同的字符串。
function convertSTR(str)
if not string.find(str,"//") then
return str
else
replace //...// with convertToRoman(...)
end
return str
end
我知道我可以用它string.find来获得完整的\\...\\序列。有没有更简单的模式匹配或类似的解决方案?