CAPL Script

StrstrRegex

This reference collection includes Vector documentation reproduced with permission. Snippets may require configuration-specific symbols and are not all standalone programs. Sources and validation limits.

Syntax

long strstr_regex(char s[], char pattern[])

long strstr_regex_off(char s[], long offset, char pattern[])

Function

Searches for a regular expression pattern in a string.

Parameters

s String to be searched.

offset

Offset in s at which the search shall be started.

pattern

Regular expression which is searched. For the regular expression, the same syntax is used as in the Perl programming language.

Return Values

The position in s where the pattern was found, or -1 if it wasn’t found.

Reference example from the CANoe 12 help. Check the required configuration, database objects and API availability in your installed version; this is not a recorded compiler or runtime test.

char buffer[70] = "Vector Informatik";
long res;
res = strstr_regex(buffer, "Inf[a-z]*"); // 7
res = strstr_regex_off(buffer, res + 1, "Inf[a-z]*"); // -1

str_match_regex | str_replace | str_replace_regex | String Literal