文字列フォーマッタ

Version 23.4.8841


文字列フォーマッタ


一般的な文字列フォーマッタ

The following string formatters are among the most commonly used. An example of each formatter is provided for reference.

contains(target[, ifcontains][, ifnotcontains])

Returns true if the input string contains the target, and false otherwise.

The ifcontains parameter can be set to an alternate value to return if the input string contains the target, and the ifnotcontains parameter can be set to an alternate value to return if the input string does not contain the target.

Example

<arc:set attr="myString" value="hello world" />
<arc:if exp="[myString | contains('hello')]">
  <arc:set attr="response" value="hello to you too!" />
  <arc:else>
    <arc:set attr="response" value="I would appreciate a greeting" />
  </arc:else>
</arc:if>

def(ifnotexists[, ifexists])

Sets the ‘default’ value of an attribute: if the attribute has not yet been set to a value, set it to the value passed in ifnotexists; if the attribute already exists, set it to the value passed in ifexists.

Example

<!-- count the number of loops in an XML document using xmlDOMSearch -->

<arc:set attr="xml.uri" value="[FilePath]" />
<arc:set attr="xml.xpath" value="/Items/test/loop" />

<arc:call op="xmlDOMSearch" in="xml">
  <!-- this code will execute for each occurrence of the 'xpath' in the XML document -->
  <arc:set attr="loopCount" value="[loopCount | def(0) | add(1)]" />
</arc:call>

equals(value[, ifequal][, ifnotequal])

Returns true if the input attribute matches the value, and false otherwise.

If ifequal and/or ifnotequal are provided, the values in these parameters will be returned instead of true and false, respectively.

Example

<arc:set attr="myItem.code" value="[xpath(data/lineitems/itemcode)]" />
<arc:if exp="[myItem.code | equals('A5')]">
  <arc:set attr="myItem.name" value="spoon" />
  <arc:else>
    <arc:set attr="myItem.name" value="fork" />
  </arc:else>
</arc:if>

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()]" />

guid(includehyphens)

Generates a globally-unique identifier (GUID) value. By default, the formatter returns all of the characters in a single, unformatted string. To include hyphens that conform to the standard 8-4-4-4-12 GUID format, use the includehyphens parameter, and set it to true.

This formatter does not modify the input attribute (variable), so no such input attribute is required.

Example

<arc:set attr="myGUID" value="[guid(true)]" />

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

replace(oldvalue, newvalue[, ishex])

Searches the input string for each occurrence of oldvalue, removes it, and replaces it with newvalue.

The ishex parameter indicates if the oldvalue parameter is a hex representation of a character to replace (default false).

Example

<arc:set attr="myString" value="I hope you have a wonderful day." />
<arc:set attr="honestString" value="[myString | replace('you', 'I')]" />
<!-- honestString holds the value: I hope I have a wonderful day. -->

regexreplace(pattern, newvalue[, startindex])

Searches the input string for the regex pattern specified by pattern and replaces each occurrence with newvalue.

If the startindex parameter is provided, the search will begin at this position in the string (i.e. the formatter will ignore instances of the pattern that occur prior to startindex).

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="updatedListing" value="[myString | regexreplace([decimalPattern],'10.99')]" />
<!-- updatedListing has the value: The cost of the item is $10.99 -->

split(delimiter, indextoreturn)

Splits the input string at each occurrence of the delimiter into a set of substrings, then returns the string at the given index.

If indextoreturn is provided, then the set of substrings is indexed to return one of the substrings (e.g. passing ‘1’ as the indextoreturn would return the first substring that resulted from the split).

Example

<arc:set attr="myName" value="Walter White" />
<arc:set attr="firstName" value="[myName | split(' ',1)]" />
<!-- firstName contains the value: Walter -->

startswith(target[, iftrue][, iffalse])

Returns true if the input string starts with the value specified as the target, and false otherwise.

If iftrue is provided, this value is returned instead of true when the target is found, and if iffalse is provided, this value is returned instead of false when the target is not found.

Example

<arc:set attr="myString" value="Sir, your carriage is ready." />
<arc:if exp="[myString | startswith('Sir')"]>
  <arc:set attr="response" value="Thank you." />
  <arc:else>
    <arc:set attr="response" value="Use your manners." />
  </arc:else>
</arc:if>

substring(index[, length])

Returns a substring of the input string value, starting at the index value and ending length characters later. If length is not provided, the substring will end at the end of the original string.

Example

<!-- parse out the characters before the first comma, combining substring() with find() -->

<arc:set attr="myString" value="Luke, I am your father". />
<arc:set attr="commaPosition" value="[myString | find(',')]" />
<arc:set attr="introClause" value="[myString | substring(0, [commaPosition])]" />
<!-- introClause has the value: Luke -->

trim()

Removes leading and trailing whitespace from the input string.

Example

<arc:set attr="uglyString" value="    here is some data.  " />
<arc:set attr="prettyString" value="[uglyString | trim()]" />

Vault(ItemName)

Returns the value of an item in the Global Settings Vault that matches the provided value for ItemName.

Note:Use caution when referring to encrypted vault items in scripting contexts to ensure that sensitive information is not included in the logs.

Example

<arc:set attr="URLtoResource" value="[Vault(commonURL)]" />

その他の文字列フォーマッタ

Below is the list of less-common formatters, grouped by functionality.

Capitalization Formatters

capitalize()

最初の文字のみを大文字にした元の属性値を返します。

capitalizeall()

すべての単語の最初の文字を大文字にした元の属性値を返します。

tolower()

すべての文字が小文字に変換された属性値で表される文字列を返します。

toupper()

すべての文字が大文字に変換された属性値で表される文字列を返します。

Encoding/Decoding Formatters

base64decode()

属性値をBase64 デコードされた文字列に変換します。

base64encode()

属性値をBase64 エンコードされた文字列に変換します。

jsonescape()

属性値をJSON エスケープされた単一行の文字列に変換します。

md5hash([converttobase64])

属性値のMD5 ハッシュを計算します。

  • encodetobase64:結果をbase 64 エンコード文字列に変換するかどうかを指定するboolean 値(オプション)。デフォルトはtrue です。

sha1hash([converttobase64])

属性値のSHA-1 ハッシュを計算します。

  • encodetobase64:結果をbase 64 エンコード文字列に変換するかどうかを指定するboolean 値(オプション)。デフォルトはtrue です。

sqlescape()

属性値をSQL エスケープされた単一行の文字列に変換します。

  • dbtype:エンコードするデータベースの種類。SQL またはSQLite が使用可能です。デフォルトはSQL です。

xmldecode()

属性値をXML デコードされた文字列に変換します。

xmlencode()

属性値をXML エンコードされた文字列に変換します。

Joining Formatters

concat([newString])

Concatenates the value piped into the formatter with the parameter passed to the formatter

  • newString:The string to append to the attribute.

join([separator])

implode([separator])

複数の値を区切り文字で区切られた文字列に分解します。

  • separator:区切り文字(オプション)。

print([delim])

指定された区切り文字を使用して連結された属性のすべての値を含む文字列を返します。

  • delim:値を区切る区切り文字(オプション)。デフォルトはカンマです。

Logical Formatters

allownull()

属性が存在しない場合はNULL、存在する場合は値を返します。

empty(value)

属性値が空の場合は指定された値を返し、それ以外の場合は元の属性値を返します。

  • value:属性が空の場合に使用される値。

ifequal(value[, ifequals][, ifnotequals])

属性値を最初のパラメータの値と比較して、同じ場合はtrue(またはifequals)を返し、それ以外の場合はfalse(またはifnotequals)を返します。

  • value:属性値と比較する文字列。
  • ifequals:属性値が最初のパラメータで表される値と等しい場合に返される値(オプション)。
  • ifnotequals:属性値が最初のパラメータで表される値と等しくない場合に返される値(オプション)。

ifmatches(value[, ifmatch][, ifnotmatch])

属性値が最初のパラメータと一致する場合はtrue(またはifmatch)を返し、それ以外の場合はfalse(またはifnotmatch)を返します。

  • value:属性値と比較される値。
  • ifmatch:属性値がパラメータ値と一致する場合に返される値(オプション)。
  • ifnotmatch:属性値がパラメータ値と一致しない場合に返される値(オプション)。

isalphabetic([ifalpha][, ifnotalpha])

属性値のすべての文字がアルファベットで、少なくとも1つの文字がある場合はtrue(またはifalpha)を返し、それ以外の場合はfalse(ifnotalpha)を返します。

  • ifalpha:属性値がアルファベットの場合に返される値(オプション)。
  • ifnotalpha:属性値がアルファベットではない場合に返される値(オプション)。

isalphanumeric([ifalphanum][, ifnotalphanum])

属性値のすべての文字が英数字で、少なくとも1つの文字がある場合はtrue(またはifalphanum)を返し、それ以外の場合はfalse(ifnotalphanum)を返します。

  • ifalphanum:属性値がアルファベットまたは数字のみを含む場合に返される値(オプション)。
  • ifnotalphanum:属性値が非アルファベットまたは非数字のみを含む場合に返される値(オプション)。

islower([iflower][, ifnotlower])

属性値のすべての文字が小文字で、少なくとも1つの文字がある場合はtrue(またはiflower)を返し、それ以外の場合はfalse(ifnotlower)を返します。

  • iflower:属性値が小文字の場合に返される値(オプション)。
  • ifnotlower:属性値が小文字ではない場合に返される値(オプション)。

isnumeric([ifnum][, ifnotnum])

属性値のすべての文字が数字で、少なくとも1つの文字がある場合はtrue(またはifnum)を返し、それ以外の場合はfalse(ifnotnum)を返します。

  • ifnum:属性値が数字の場合に返される値(オプション)。
  • ifnotnum:属性値が数字ではない場合に返される値(オプション)。

isspace([ifspace][, ifnotspace])

属性値が空白文字のみで、少なくとも1つの文字がある場合はtrue(またはifspace)を返し、それ以外の場合はfalse(ifnotspace)を返します。

  • ifspace:属性値が空白の場合に返される値(オプション)。
  • ifnotspace:属性値が空白でない場合に返される値(オプション)。

isupper([ifupper][, ifnotupper])

属性値のすべての文字が大文字で、少なくとも1つの文字がある場合はtrue(またはifupper)を返し、それ以外の場合はfalse(ifnotupper)を返します。

  • ifupper:属性値が大文字の場合に返される値(オプション)。
  • ifnotupper:属性値が大文字ではない場合に返される値(オプション)。

notequals(value[, notequals][, equals])

属性値を最初のパラメータの値と比較します。異なる場合はtrue(またはnotequals)、等しい場合はfalse(またはequals)を返します。

  • value:属性値と比較する文字列。
  • notequals:属性値が最初のパラメータで表される値と等しくない場合に返される値(オプション)。
  • equals:属性値が最初のパラメータで表される値と等しい場合に返される値(オプション)。

Parsing Formatters

count(substring)

最初のパラメータで指定された部分文字列の属性値の出現回数を返します。

  • substring:属性値で検索する部分文字列。

remove(integer_index[, integer_count])

属性値から文字を削除します。最初のパラメータで指定されたゼロベースのインデックスから始まります。

  • index:文字の削除を開始する位置。
  • count:削除する文字数(オプション)。指定しない場合は、指定されたインデックスから始まるすべての文字が削除されます。

striphtml()

HTML マークアップが削除された文字列を返します。

rsplit(delimiter, integer_index)

属性値で表される文字列を、最初のパラメータで区切られたトークンに分割し、2番目のパラメータで指定されたインデックスのトークンを返します。右から数えます。

  • delimiter:文字列をトークンに分割するための区切り文字として使用される文字列。
  • index:最初のトークンがインデックス1にある場合にリクエストされるトークンのインデックス。

toalpha()

文字列内の文字のみを返します。

toalphanum()

文字列内の英数字のみを返します。

truncate(integer_count)

属性値を、パラメータで指定された文字数に切り捨てます。

  • count:結果の文字列の文字数。

Searching Formatters

arrayfind(substring)

属性配列で文字列が見つかったときのインデックスを返します。インデックスは1ベースです。

  • searchstring:元の値で検索する文字列。

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

属性値が指定されたパラメータで終わるかどうかを決定します。属性が値で終わっている場合はtrue(またはiftrue)を返し、それ以外の場合はfalse(またはiffalse)を返します。

  • substring:最後に期待される文字列。
  • iftrue:属性値がパラメータ値で終わる場合に返される値(オプション)。
  • iffalse:属性値がパラメータ値で終わらない場合に返される値(オプション)。

insert(integer_index, string)

指定したインデックスに指定した文字列を挿入します。

  • index:新しい文字列が挿入される元の値の位置のゼロベースのインデックス。
  • string:元の値に挿入する文字列。

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

属性値で表される文字列から、pattern パラメータで指定された正規表現が出現しているものを検索します。

  • pattern:一致する正規表現パターン。
  • index:返す一致の番号付きインデックス(オプション)。デフォルトは0です。
  • option:正規表現オプションのカンマ区切りリスト(オプション)。一般的に使用されるオプションは、IgnoreCase、Multiline、Singleline、およびIgnorePatternWhitespace です。

regex(pattern[, index][, option])

属性値で表される文字列から、pattern パラメータで指定された正規表現が出現しているものを検索します。

  • pattern:一致する正規表現パターン。
  • index:返す一致の番号付きインデックス(オプション)。デフォルトは0です。
  • option:正規表現オプションのカンマ区切りリスト(オプション)。一般的に使用されるオプションは、IgnoreCase、Multiline、Singleline、およびIgnorePatternWhitespace です。

rfind(substring[, integer_startindex])

属性値で部分文字列が見つかったときのゼロベースの最大のインデックスを返します。

  • substring:元の値で検索する文字列。
  • startindex:検索を開始するインデックス(オプション)。

Whitespace Formatters

center(integer_width[, character])

最初のパラメータで指定された幅の文字列の中心の属性値を返します。パディングは、2番目のパラメータで指定されたfillchar を使用して行われます。

  • width:出力文字列の合計幅。
  • character:パディングに使用される文字(オプション)。指定されていない場合、デフォルトはスペースになります。

expandtabs([integer_width])

属性値にあるすべてのタブ文字をスペースに置き換えます。パラメータで指定されたタブサイズが指定されていない場合は、デフォルトの8文字のタブサイズが使用されます。

  • width:タブ幅(オプション)。指定しない場合のデフォルトは8です。

just(integer_width[, character])

最初のパラメータで指定した長さの文字列で左揃えされた属性値を返します。パディングは、2番目のパラメータで指定されたfillchar を使用して行われます。

  • width:出力文字列の合計幅。
  • character:パディングに使用される文字(オプション)。デフォルトはスペースです。

nowhitespace()

属性値で表される文字列から空白を削除します。

ljust(integer_width[, character])

最初のパラメータで指定した長さの文字列で左揃えされた属性値を返します。パディングは、2番目のパラメータで指定されたfillchar を使用して行われます。

  • width:出力文字列の合計幅。
  • character:パディングに使用される文字(オプション)。デフォルトはスペースです。

rjust(integer_width[, character])

2番目のパラメータで指定した長さの文字列で右揃えされた属性値を返します。パディングは、最初のパラメータで指定されたfillchar を使用して行われます。

  • width:出力文字列の合計幅。
  • character:パディングに使用される文字(オプション)。指定されていない場合、デフォルトはスペースになります。

trimend()

属性の末尾の空白を削除します。

trimstart()

属性の先頭の空白を削除します。

wordwrap([integer_width][, break][, cut][, wrapexp])

Wraps a string to a certain width while respecting word boundaries.

  • width:The maximum line length after wrapping the string.
  • break:The character(s) used to break the string; the default value is CRLF (e.g. ‘\r\n’).
  • cut:指定された幅で、またはその前で文字列を折り返すかどうかを指定するboolean 値(オプション)。デフォルトはfalse です。
  • wrapexp:A regex expression representing the characters to replace when “breaking” the string; the default is the ‘space’ character (this default is intended for strings consisting of words separated by spaces). To break a string unconditionally without respecting word boundaries, set this paramater to empty string: ‘’