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

# Searching Formatters

> Formatters for searching, matching, and measuring string values in ArcScript.

## count(substring)

Returns the number of occurrences in the attribute value of a substring specified by the first parameter.

* **substring**: The substring to search for in the attribute value.

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

Determines whether the attribute value ends with the specified parameter. Returns *true* (or *iftrue*) if the attribute ends with the value, and *false* (or *iffalse*) if not.

* **substring**: The string expected at the end.
* **iftrue**: The optional value returned if the attribute value ends with the parameter value.
* **iffalse**: The optional value returned if the attribute value does not end with the parameter value.

## find(target\[, startindex])

Searches the input string and returns the position in this string where the *target* first appears (zero-based index).

If *startindex* is provided, the formatter starts searching for the *target* starting at this index in the input string (in other words, it ignores instances of the *target* that appear earlier than *startindex*).

### Example

```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()

Returns the number of characters in the input attribute.

### Example

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

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

Searches the string represented by the attribute value for an occurrence of the regular expression supplied in the *pattern* parameter.

* **pattern**: The regular expression pattern to match.
* **index**: The optional numbered index of the match to return. The default is `0`.
* **option**: The optional comma-separated list of regular expression options. Some of the commonly used options are IgnoreCase, Multiline, Singleline, and IgnorePatternWhitespace.

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

Searches the input string for the regex pattern specified by *pattern* and returns the first set of characters that match the pattern.

* **pattern**: The regular expression pattern to match.
* **index**: The optional numbered index of the match to return. The default is `0`.
* **option**: The optional comma-separated list of regular expression options. Some of the commonly used options are IgnoreCase, Multiline, Singleline, and IgnorePatternWhitespace.

### Example

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