9951 explained code solutions for 126 technologies


luaRegex match and replace


local str = 'Hi, Donald! Do you like Joe?';
local str1 = str:gsub('D.+\\?!', 'Bill')ctrl + c
local str

sample string to find and replace in based on regex

gsub

will match and replace found strings based on regex

str1

will contain final string

'D.+\\?!'

regex to match

'Bill'

string to replace matched substrings with