substitute
string string string
substitute は「元に戻す」が不可能、「照会」が不可能、「編集」が不可能です。
第 1 引数の正規表現にマッチする部分を第 2 引数(入力文字列)から検索し、第 3 引数の文字列で置き換えます。入力文字列に正規表現とマッチする箇所がない場合、元の文字列が変更されずに返されます。 正規表現の使い方についての詳細は、match コマンドのドキュメントを参照してください。string | 代入文字列 |
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%-".