Caplin Trader 4.8.0

Class: module:caplin/element/formatter/RegExpFormatter

module:caplin/element/formatter/RegExpFormatter

Constructor

new module:caplin/element/formatter/RegExpFormatter()

Transforms a string using a standard JavaScript regular expression.

RegExpFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following examples which evaluate to "8987551787.0" and "Buy USD" respectively:

caplin.element.formatter.RegExpFormatter.format("8987551787.0", { match:"[A-Z]" })
caplin.element.formatter.RegExpFormatter.format("Buy.USD", { match:"(\\.", replace:" " })
Implements:

Methods

format(vValue, mAttributes) → {String}

Transforms a string using a standard JavaScript regular expression. By default, only the first match is substituted with the replacement string (unless the "g" option is supplied) and the match is case sensitive (unless the "i" option is supplied).
Parameters:
Name Type Description
vValue Variant the string.
mAttributes Map the map of attributes.
Properties
Name Type Attributes Default Description
match String The string to match (a standard js RegExp).
replace String <optional>
'' The string to use as replacement.
flags String <optional>
The regular expression flags to be applied (standard js RegExp flags).
Returns:
the string, converted by the regular expression.
Type
String