> ## 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 -->
```
