Skip to main content
Open topic with navigation CAPL Functions » General » Function Overview » str_replace

str_replace

Valid for: CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DE

Function 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

Description

  • 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 buffer s.

Example

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