Caplin Trader 5.1.0

Class: module:ct-element/parser/RegExpParser

module:ct-element/parser/RegExpParser()

new module:ct-element/parser/RegExpParser()

Transforms a string against a standard JavaScript regular expression.

RegExpParser is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following examples which evaluate to null (match failed), 'simple' and 'sample' respectively:

RegExpParser.parse('simple', {match:'z'})
RegExpParser.parse('simple', {match:'i'})
RegExpParser.parse('simple', {match:'i', replace:"a"})
Implements:

Methods

parse(value, mAttributes) → {String}

Transforms a string against a standard JavaScript regular expression.

If the string matches, then the function replaces the matched part with the replace expression, otherwise the function return null.

Parameters:
Name Type Description
value String

the string to parse.

mAttributes Map

a list of attributes, as specified in module:ct-element/formatter/RegExpFormatter.

Returns:

replacement string upon match, otherwise null.

Type
String