リスト内のサブストリングを置き換えます。
パラメータ | 説明 |
---|---|
sourceList | 検索するリスト。 |
fromList | 検索サブストリングが含まれるリスト。ここで指定する検索サブストリングは、大文字と小文字の区別を含め、ソースリスト内の要素と正確に一致する必要があります。 |
toList | 置き換え用のストリングが含まれるリスト。このリストは、検索対象のリストと同じ長さで指定する必要があります。 |
戻り値 | 説明 |
---|---|
any | fromList の要素と sourceList の要素を比較し、一致するサブストリング要素がある場合は、sourceList の要素を toList の要素で置き換えて返します。 |
ストリング要素の一部を置き換える場合に、この関数を使用します。リストの要素全体を置き換える場合は、@Replace (JavaScript) 関数を使用します。
function p(stuff) {
print("<<<" + stuff + ">>>");
}
var cities = @List("The town of Moscow",
"The town of London",
"The town of Moscow",
"The town of Moscow");
var from = @List("town");
var to = @List("city");
cities = @ReplaceSubstring(cities, from, to);
for(var i = 1; i <= @Count(cities); i++) {
p(i + " " + @Element(cities, i));
}
/*
<<<1 The city of Moscow>>>
<<<2 The city of London>>>
<<<3 The city of Moscow>>>
<<<4 The city of Moscow>>>
*/