The provided answers will work were you loop through the array and replace the text for each swear word.
You could also use a regex to replace the swear words in one replacement.
var r = RegEx.new()
var string = "This is a text full of swear words like swear1 or swear2 and even swear3. It even gets repeated swear1, swear2"
var replacedstring = r.sub(string, "* * *", true)
This is a text full of swear words like * * * or * * * and even * * *. It even gets repeated * * *, * * *