Page 1 of 1

[help] replacing words

Posted: Sat Jan 16, 2016 2:19 am
by herbert
So I been trying to code something to replace certain words in a sentance for what I TYPE.

Example I type

GT Hello, How is everyone?

for it to send

GT greetings, How is everyone?

So it'll replace hello with greeting. The part im having issues with is, IF Hello is the third word in the sentence such as, gt oh, my, hello, how are you? for it still replace hello with greetings.

Anyone have a clue how I could go about this?

the hello and greeting are examples and I would like to add more words to replace other words so to speak.

Re: [help] replacing words

Posted: Sun Jan 17, 2016 3:33 am
by Drevarr
how about gsub?
Code: [show] | [select all] lua
str = string.gsub(matches[2], "Hello", "Greetings")
send("GT "..str)

Re: [help] replacing words

Posted: Sun Jan 17, 2016 4:33 am
by herbert
oh, string.gsub, Thanks!