Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findAndReplace(string,data,replacedata)
- if not type(string) == "string" and type(data) == "string" and type(replacedata) == "string" then error("All 3 vars must be strings") end
- while true do
- pos = string.find(string,data)
- if pos==nil then break end
- j=j or true
- string=string..""
- local offset=string.len(string)+string.len(replacedata)
- offset=offset-string.len(data)
- local lastpos=pos + string.len(replacedata)
- string = string.sub(string, 1, pos-1)..replacedata..string.sub(string, lastpos,string.len(string)+offset)
- end
- return j and string
- end
Advertisement
Add Comment
Please, Sign In to add comment