LlReplaceSubString/ja
< LlReplaceSubString
Jump to navigation
Jump to search
Revision as of 13:15, 2 November 2023 by Misaki Vanilla (talk | contribs)
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
要約
関数: string llReplaceSubString( string src, string pattern, string replacement_pattern, integer count );that is the result of replacing the first count matching instances pattern in src with replacement_pattern.を string で返します。
• string | src | |||
• string | pattern | |||
• string | replacement_pattern | |||
• integer | count |
If count = 0, all matching substrings are replaced. If count > 0, substrings are replaced starting from the left/beginning of src. If count < 0, substrings are replaced starting from the right/end of src.
サンプル
default
{
state_entry()
{
string ex = "red foxes, red hens, red turnips";
// Replace first 2 matches, starting from the left side
ex = llReplaceSubString(ex, "red", "blue", 2);
llSay(0, ex); // Should say "blue foxes, blue hens, red turnips"
}
}
default
{
state_entry()
{
string ex = "red foxes, red hens, red turnips";
// Replace first match, starting from the right side
ex = llReplaceSubString(ex, "red", "green", -1);
llSay(0, ex); // Should say "red foxes, red hens, green turnips"
}
}
default
{
state_entry()
{
string ex = "red foxes, red hens, red turnips";
// Replace all matches
ex = llReplaceSubString(ex, "red", "yellow", 0);
llSay(0, ex); // Should say "yellow foxes, yellow hens, yellow turnips"
}
}
関連項目
特記事項
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。