shervin
04-07-2007, 03:20 PM
Im trying to replace a list of words with some other word, like this:
--------------------------------------------------------------------------------------
input = "word1 word2 word3 word4 word5";
pattern = "(word2|word4)";
replacestring = "someword";
string.gsub( input, pattern, replacestring);
--------------------------------------------------------------------------------------
but it doesn't work. it works in other languages though.
It matches the whole string all the time.
I want the result to be: "word1 someword word3 someword word5"
Any help would be useful, I would like to do this with regex instead of search & replace.
--------------------------------------------------------------------------------------
input = "word1 word2 word3 word4 word5";
pattern = "(word2|word4)";
replacestring = "someword";
string.gsub( input, pattern, replacestring);
--------------------------------------------------------------------------------------
but it doesn't work. it works in other languages though.
It matches the whole string all the time.
I want the result to be: "word1 someword word3 someword word5"
Any help would be useful, I would like to do this with regex instead of search & replace.