CAPL Script

StrReplace

Syntax

long str_replace(char s[], char searched[], char replacement[]); // form 1

long str_replace(char s[], long startoffset, char replacement[], long length); // form 2

Function

Form 1: Replaces all occurrences of a text in a string with another string. Form 2: Replaces a part of a string with another string.

Parameters

s String to be modified.

searched

Text which shall be replaced.

startoffset

Offset at which to start replacing characters.

replacement

Text which replaces the original characters.

length

Maximum number of characters to replace.

Return Values

1 if successful, 0 if the resulting string would be too long for the buffers.

char buffer[70] = "Vector Informatik";str_replace(buffer, "Informatik", "CANoe");write(buffer);str_replace(buffer, 7, "CANalyzer", 10);write(buffer);

str_match_regex | str_replace_regex | strstr_regex | String Literal