> ## 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 中搜索、匹配和测量字符串值的格式化器。

## count(substring)

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

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

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

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

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

## find(target\[, startindex])

搜索输入字符串，并返回 *target* 首次出现的位置（从 0 开始的索引）。

如果提供了 *startindex*，格式化器会从输入字符串中的该索引开始搜索 *target*（换句话说，它会忽略早于 *startindex* 出现的 *target* 实例）。

### 示例

```xml theme={null}
<arc:set attr="myString" value="Please excuse my dear Aunt Sally." />
<arc:set attr="whereIsSally" value="[myString | find('Sally')]" />
<!-- whereIsSally has the value: 27 -->
```

## getlength()

返回输入属性中的字符数。

### 示例

```xml theme={null}
<arc:set attr="myString" value="hello world" />
<arc:set attr="stringLength" value="[myString | getlength()]" />
```

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

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

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

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

在输入字符串中搜索 *pattern* 指定的正则表达式模式，并返回与该模式匹配的第一组字符。

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

### 示例

```xml theme={null}
<arc:set attr="myString" value="The cost of the item is $12.98." />
<arc:set attr="decimalPattern" value="\[0-9\]+\.?\[0-9\]*" />
<arc:set attr="price" value="[myString | regexmatch([decimalPattern])]" />
<!-- price has the value: 12.98 -->
```
