> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 数组格式化器

> ArcScript 中用于处理数组属性的格式化器，可跨多个数组元素返回聚合值或搜索值。

export const siteNameShort = "知行之桥";

以下格式化器期望数组属性作为输入。数组属性是项目上分配有多个值的单个属性。{siteNameShort}Script 中的数组属性在属性末尾用井号 (`#`) 表示（例如 `tmp.myarrayitem#`）。有关详细信息，请参阅[选择属性值](../operations/operations)。

<Note>
  * 将数组属性传递给这些格式化器时，不需要 `#` 符号。
  * 某些格式化器的可选参数周围的方括号不是必需的；它们仅用于表示该参数是可选的。
</Note>

## arrayaverage(\[integer\_rounding\_mode]\[decimal\_places])

返回属性数组元素的平均值。

* **rounding\_mode**：指定可能丢弃精度的数值运算的舍入行为。可接受的值包括：`ToEven`、`AwayFromZero`、`ToZero`、`ToNegativeInfinity`、`ToPositiveInfinity`。默认舍入策略取决于操作系统。.NET 使用 <a href="https://learn.microsoft.com/en-us/dotnet/api/system.midpointrounding?view=net-6.0" target="_blank">ToEven</a>，Java 使用 <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/RoundingMode.html#HALF_EVEN" target="_blank">Half Even</a>。

还可以指定全局 `RoundingMode` 环境变量，并将其中一个 `rounding_mode` 值作为其值。这样做时，只要格式化器中未明确指定 `rounding_mode`，{siteNameShort} 就会使用该舍入模式。更具体地说，{siteNameShort} 会按以下顺序检查值：

1. `rounding_mode` 输入
2. `RoundingMode` 环境变量
3. 如上所述，由操作系统确定的默认值

## arrayfind(substring)

返回在属性数组中找到对应字符串的索引。索引从 1 开始。

* **searchstring**：在原始值中搜索的字符串。

## count(substring)

返回属性值中第一个参数指定的子字符串的出现次数。

* **substring**：要在属性值中搜索的子字符串。

## endswith(substring\[, iftrue]\[, iffalse])

确定属性值是否以指定参数结尾。如果属性以该值结尾，则返回 *true*（或 *iftrue*）；否则返回 *false*（或 *iffalse*）。

* **substring**：预期出现在结尾处的字符串。
* **iftrue**：如果属性值以参数值结尾，则返回的可选值。
* **iffalse**：如果属性值不以参数值结尾，则返回的可选值。

## implode(\[separator])

将多个值组合为一个由分隔符分隔的字符串。

* **separator**：可选的分隔符。

## join(\[separator])

将多个值连接为一个由分隔符分隔的字符串。

* **separator**：可选的分隔符。

## match(pattern\[, index]\[, option])

在属性值所表示的字符串中搜索 *pattern* 参数提供的正则表达式。

* **pattern**：要匹配的正则表达式模式。
* **index**：要返回的匹配项的可选编号索引。默认值为 `0`。
* **option**：可选的逗号分隔正则表达式选项列表。常用选项包括 IgnoreCase、Multiline、Singleline 和 IgnorePatternWhitespace。

## print(\[delim])

返回一个字符串，其中属性的所有值使用指定分隔符连接在一起。

* **delim**：用于分隔值的可选分隔符。默认值为逗号。
