Regular expressions

Tosca Cloud supports regular expressions, which are used to compare whether the target attribute contains a string that matches the regular expression. The regular expression must be specified within double quotation marks.

The .NET Framework syntax is used for regular expressions in Tosca Cloud.

Syntax:

{REGEX["regular expression"]}

A leading escape character is required in order to allow quotation marks to be used accordingly in the regular expression.

Random numbers and regular expressions

Random text is specified by using regular expressions. The regular expression must be specified using double quotation marks.

Syntax:

{RANDOMREGEX["<Regular expression>"]}

{RANDOMREGEX["^[A-Z][a-z]+[0-9]{4}$"]}

A value starting with a capital letter from A-Z is generated, followed by any number of lower case letters and exactly four digits between 0-9. The ^ character denotes the beginning of the line, and the $ character the end of the line.

The generated expression is for instance: Ecqwp1989.

Regular expressions and buffers

Please note that buffers and regular expressions can only be used if the buffer is part of the regular expression:

Syntax:

{REGEX["Regular expression"{B[BufferName]}"Regular expression"]}

{REGEX[{B[B_12345]} "(iteration [0-9]{4})"]}

This expression can for instance be used to verify the following string: E610Overviewprocess (iteration 0012). In this example, it is assumed that the value E610Overviewprocess was written to the buffer B_12345 beforehand.

Extracting text using regular expressions

You can use regular expressions to verify and extract dynamic parts of a string. Tosca Cloud saves these values to buffers for later use.

Named groups specify the name of the buffer and the required pattern of the value.

Use the action mode Verify.

Syntax:

{REGEX["expression(?<buffer name>subexpression)expression"]}

Expression: any regular expression specifying the static parts.

Buffer name: this is the name for the buffer to which the dynamic part of the comparison is saved.

Subexpression: this defines the dynamic part which should be buffered.

The part (?<buffer name>subexpression) is called named group.

Be aware that the buffer name of a named group has to contain at least one word character.