You are here: Part 2: Core Concepts > Topics > ContentFilteredTopics > STRINGMATCH Filter Expression Notation

STRINGMATCH Filter Expression Notation

The STRINGMATCH Filter is a subset of the SQL filter; it only supports the MATCH relational operator on a single string field. It is introduced mainly for the use case of partitioning data according to channels in the DataWriter's MULTI_CHANNEL QosPolicy (DDS Extension) in Market Data applications.

A STRINGMATCH filter expression has the following syntax:

<field name> MATCH <string pattern>

The STRINGMATCH filter is provided to support the narrow use case of filtering a single string field of the DDS sample against a comma-separated list of matching string values. It is intended to be used in conjunction with ContentFilteredTopic helper routines append_to_expression_parameter() (Appending a String to an Expression Parameter) and remove_from_expression_parameter() (Removing a String from an Expression Parameter), which allow you to easily append and remove individual string values from the comma-separated list of string values.

The STRINGMATCH filter must contain only one <field name>, and a single occurrence of the MATCH operator. The <string pattern> must be either the single parameter %0, or a single, comma-separated list of strings without intervening spaces.

During creation of a STRINGMATCH filter, the <string pattern> is automatically parameterized. That is, during creation, if the <string pattern> specified in the filter expression is not the parameter %0, then the comma-separated list of strings is copied to the initial contents of parameter 0 and the <string pattern> in the filter expression is replaced with the parameter %0.

The initial matching string list is converted to an explicit parameter value so that subsequent additions and deletions of string values to and from the list of matching strings may be performed with the append_to_expression_parameter() and remove_from_expression_parameter() operations mentioned above.

Example STRINGMATCH Filter Expressions

This expression evaluates to TRUE if the value of symbol is equal to NASDAQ/MSFT:

    symbol MATCH 'NASDAQ/MSFT'  

This expression evaluates to TRUE if the value of symbol is equal to NASDAQ/IBM or NASDAQ/MSFT:

	symbol MATCH 'NASDAQ/IBM,NASDAQ/MSFT'

This expression evaluates to TRUE if the value of symbol corresponds to NASDAQ and starts with a letter between M and Y:

	symbol MATCH 'NASDAQ/[M-Y]*'

STRINGMATCH Filter Expression Parameters

In the builtin STRINGMATCH filter, there is one, and only one, parameter: parameter 0. (If you want to add more parameters, see Appending a String to an Expression Parameter.) The parameter can be specified explicitly using the same syntax as the SQL filter or implicitly by using a constant string pattern. For example:

symbol MATCH %0  (Explicit parameter)
symbol MATCH ‘IBM’ (Implicit parameter initialized to IBM)

Strings used as parameter values must contain the enclosing quotation marks (') within the parameter value; do not place the quotation marks within the expression statement. For example, the expression " symbol MATCH %0 " with parameter 0 set to " 'IBM' " is legal, whereas the expression " symbol MATCH '%0' " with parameter 0 set to " IBM " will not compile.

© 2016 RTI