Searching Formatters

Version 24.1.8906


Searching Formatters


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 will start searching for the target starting at this index in the input string (i.e. will ignore instances of the target that appear earlier than startindex).

Example

<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

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

The index parameter can be used to find occurrences other than the first; for example, providing ‘1’ for the index will find the second occurrence, and providing ‘2’ as the index will find the third occurrence. The option parameter accepts an optional comma-separated list of regular expression options (e.g. IgnoreCase, Multiline, Singleline, and IgnorePatternWhitespace).

Example

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