Next Previous Contents

62. str_replace

Synopsis

Replace a substring of a string

Usage

Integer_Type str_replace (String_Type a, String_Type b, String_Type c)

Description

The str_replace function replaces the first occurance of b in a with c and returns an integer that indicates whether a replacement was made or not. If b does not occur in a, zero is returned. However, if b occurs in a, a non-zero integer is returned as well as the new string resulting from the replacement.

Example

  define str_replace_all (orig, match, replacement)
  {
     while (str_replace (orig, match, replacement))
        orig = ();
     return orig;
  }
is a function that replaces all occurances in a string.
See Also

is_substr, strsub, strtrim


Next Previous Contents