TC String Operations

The Module TC String Operations is used to modify or verify strings by using regular expressions. In the Settings dialog, buffer variables can be created, and buffer values can be read, verified or edited.

The Module is part of the AidPack package, which you can download from the Tricentis Support Portal as described in chapter "Exchange Portal".

For further information on licenses, please contact Tricentis Support.

ModuleAttribute

Description

Value

The ModuleAttribute Value specifies the string to be either verified or modified. The ActionMode Input must be selected.

Operation

The ModuleAttribute Operation specifies the action to be performed. The ActionMode Input must be selected here.

Possible values:

  • Search: the value that has been specified for the ModuleAttribute Pattern is searched for.

  • Replace: the value that has been specified for the ModuleAttribute Pattern is searched for. This value is replaced by the value that has been specified for the ModuleAttribute ReplaceBy.

  • Test: the system verifies whether the value that has been specified for the ModuleAttribute Pattern exists in the string or not. Correspondingly, the value must be set to either True or False in the ModuleAttribute Result .

  • Global: if this value is specified, all matching search results are included.

  • IgnoreCase: if this value is specified, case-sensitivity is ignored during the search process.

Syntax:

The following commands are used in the syntax along with Global or IgnoreCase: Search, Replace or Test. The values must be separated by dots. Example: Replace.Global

Pattern

The ModuleAttribute Pattern specifies whether a string or regular expressions of the Microsoft® VBScript RegExp Object are used for the search. The ActionModeInput must be selected.

Special characters, which should be interpreted as values instead of regular expressions, require a leading backslash \ to be used as a prefix.

Example: if $5 should be used as a value in a string, this has to be specified as follows: \$5.

ReplaceBy

The search result (Pattern) is replaced by the specified value. The ActionMode Input must be selected.

Result

If an input is performed in a TestStep, the specified value is stored in the Settings dialog as a buffer. The ActionModeInput must be selected.

If a verify action should be performed, the property to be verified is specified. The ActionMode Verify must be selected. Example: Count=1. The system verifies whether the search result (Pattern) appears exactly once in the string.

Examples

The character - which should be replaced by the following character: / is searched for. This character is included whenever it occurs if the operation Global is specified. The modified string should be stored in the Settings dialog with the buffer name BufferStringOperation.

TC String Operations - example 1

Settings dialog - Buffer

In the example below, the character / of the buffer value BufferStringOperation is replaced by the character -. This character is included whenever it occurs if the operation Global is specified.

TC String Operations - example 2

The following example verifies whether the value may appears exactly once in the string.

TC String Operations - example 3

The example below uses the regular expression ^\d+,?\d*$ to verify whether a string that contains multi-digit numbers or decimals exists.

TC String Operations - example 4