移動先: 概要 戻り値 関連項目 MEL の例

概要

substitute string string string

substitute は「元に戻す」が不可能「照会」が不可能「編集」が不可能です。

第 1 引数の正規表現にマッチする部分を第 2 引数(入力文字列)から検索し、第 3 引数の文字列で置き換えます。入力文字列に正規表現とマッチする箇所がない場合、元の文字列が変更されずに返されます。

正規表現の使い方についての詳細は、match コマンドのドキュメントを参照してください。

戻り値

string代入文字列

関連項目

match

MEL の例

string $test = "Hello -%there%-";
string $regularExpr = "-%.*%-";
string $s1 = `substitute $regularExpr $test "Mel"`;
// Result: Hello Mel //
string $s2 = `substitute "foo" $test "Mel"`;
// Result: Hello -%there%- //

// The string $s1 will contain "Hello Mel" and the string $s2 will
// contain "Hello -%there%-".