testStr = "Hello Johny !";
function do_replace(inputStr, startWord, endWord, replaceStr)
return string.gsub(inputStr, startWord .. " (%S+) " .. endWord, startWord .. " " .. replaceStr .. " " .. endWord);
end
result = do_replace(testStr, "Hello", "!", "habrahabr");
print(result);
--------------------------------------------------------------------------------
pewpew
Request data: /
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
pewpew
Request data: /favicon.ico
--------------------------------------------------------------------------------