i need to use a method with similar functionality to PHP's substr_replace.

example:

example=substr_replace("this is a test","joke",10,4);
example contains "this is a joke";

example2:

example2=substr_replace("this is a test","joke",10,0);
example2 contains "this is a joketest";