Version 0.60.0

str::replace

Replace a substring of a string by another.

Signatures

  •   string replace( string& input, string& find, string& new )

Details

The function searches input for all occurrences of find and replaces these by new.

Example

 #import( "std/str.sps" )
 echo( str::replace( "Hello world!", "world", "Lucy" ) );
 

Output

 Hello Lucy!
 

Return value

A copy of input with all occurrences of find replaced by new.

Parameters

input

Specifies the string that gets searched for the substring find. The string is not modified by the operation.

find

The substring that gets replaced inside input by new.

new

Replaces substring find inside input.

See also

🗙

Search results for