VBScript のメソッド、Replace

まんま

Function ReplaceTest(patrn, replStr)
  Dim regEx, str1                ' 変数を作成します。

  str1 = "The quick brown fox jumped over the lazy dog."
  Set regEx = New RegExp         ' 正規表現を作成します。
  regEx.Pattern = patrn          ' パターンを設定します。
  regEx.IgnoreCase = True        ' 大文字と小文字を区別しないように設定します。
  ReplaceTest = regEx.Replace(str1, replStr)  ' 置換します。
End Function

MsgBox(ReplaceTest("fox", "cat")) ' 'fox' を 'cat' で置換します。
MsgBox(ReplaceTest("(\S+)(\s+)(\S+)", "$3$2$1"))  ' 単語のペアを交換します。