Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to find words used in string from a table and then replaces the words with new one?

Asked by
RiotGUI 15
5 years ago

How to make a script that finds words used in a string from a table and then replaces the words with new one?

Here's my attempt

local stringtofind = {'are', 'you'}
local stringtoprocess = 'i think you are cool'
local startvalue,endvalue = string.find(stringtoprocess,stringtofind)
local firststring = string.sub(stringtoprocess,1,startvalue-1)
local secondstring = string.sub(stringtoprocess,endvalue+1,string.len(stringtoprocess))
local stringtoinsert = "you're"
local processedstring = firststring .. stringtoinsert ..secondstring

print(processedstring)

Any help?

0
can you clarify how it is done? because i do not understand RiotGUI 15 — 5y

Answer this question