Substring Search - Teradata Meta Data Services

Teradata Meta Data Services Programmer Guide

Product
Teradata Meta Data Services
Release Number
15.00
Language
English (United States)
Last Update
2018-09-28
Product Category
Teradata Tools and Utilities

Substring Search

Using the REGEX ComparisonOperator, character string properties can be searched for a match of a character string pattern within the property character string.

The following describes the search string value:

  • The search string value can be any character string.
  • The % and _ characters may be used in any combination in the search string
  • The % (percent sign) character represents any string of zero or more arbitrary characters.
  • The _ (spacing underscore) character represents exactly one arbitrary character.
  • Any single character is acceptable in the position in which the underscore character appears, and any string of characters is acceptable as a replacement for the percent.
  • The backslash character (\) can be used as an escape character to search for the %, _ or % characters ( \\, \%, \_ ) in the name or property value.
  • Both leading and trailing pad characters in the property field must match exactly with the search string. For example, ‘A%BC’ matches ‘AxxBC’, but not ‘AxxBΧD’, and ‘A%BΧD’ matches ‘AxxBΧD’, but not ‘AxxBC’ or ‘AxxBΧΔD’ indicates a pad character).
  • Example  

    Using the following settings in a CMetaFilterInfo object:

          filterInfo.Filter.SetPropertyID(PID_NAME);
          filterInfo.Filter.SetString(_T(“%Pres%”));
          filterInfo.SetComparisonOperator(REGEX);

    The MDS function will return objects with the following names:

          VicePresident
          President
          PresidentElect
          Elvis Presley

    Example  

    Changing the search string to:

          filterInfo.Filter.SetString(_T(“P%”));

    The MDS function will return all objects with the names beginning with the character ‘P’:

          Peterson
          Powell
          Pruitt

    Example  

    Changing the search string to:

          filterInfo.Filter.SetString(_T(“_a%”));

    Uses the % and _ characters to select a list of names with the letter A as the second letter in the name. The length of the name returned may be two or more characters. The function will return objects with the following names:

          Marston
          Watson
          Car

    If the example used _a_, the search would be for a three-character string name with the letter a as the second character. In this case, the only object returned is:

          Car