Singleton
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:" " })

Constructor Summary

Attributes Name and Description
caplin.element.formatter.RegExpFormatter()

Method Summary

Attributes Name and Description
String format(Variant vValue, Map mAttributes)

Transforms a string using a standard JavaScript regular expression.

Constructor Detail

caplin.element.formatter.RegExpFormatter()

Method Detail

String format(Variant vValue, Map 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
Variant vValue the string.
Map mAttributes the map of attributes.
Returns
the string, converted by the regular expression.