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%-".