(Ajay deleted this so I (MF) am restoring it)
How do I replace every instance of 'str1' in a input sentence? My function (ReplaceStrAll) should return the intact input sentence as its output, if it cannot find any occurrence of str1 in the input sentence.
This is the code I wrote:
function output_sentence = ReplaceStrAll(input_sentence, str1, str2) str1_index = strfind(input_sentence,str1); output_sentence = [input_sentence(1:str1_index(1)-1),str2,... input_sentence( str1_index(1)+length(str1):length(input_sentence) )];
what is wrong with it? I already got verification that I'm on the right path and I just need to make a few adjustments, but what am I messing up in the code?
Best Answer