Caplin Trader 4.7.1

Class: module:br/formatting/RegExpFormatter

module:br/formatting/RegExpFormatter

Transforms a string using a standard JavaScript regular expression.

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

br.formatting.RegExpFormatter.format("8987551787.0", { match:"[A-Z]" })
br.formatting.RegExpFormatter.format("Buy.USD", { match:"(\\.", replace:" " })

Constructor

new module:br/formatting/RegExpFormatter()

Implements:

Methods

format(vValue, mAttributes)

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

Attribute Options:

Option Description
match string to match (a standard JavaScript RegExp).
replace string to use as replacement (optional, defaults to the empty string).
flags regular expression flags (optional, standard JavaScript RegExp flags).
Parameters:
Name Type Description
vValue Variant the string.
mAttributes Map the map of attributes.
Implements:
Returns:
the string, converted by the regular expression.