Deleting a string using strrep

I am new to MATLAB scripting. I have a string to be deleted, the string comes from an array structured file. The string to be deleted is different in every loop. CanI store that changing string in a variable and delete that string using the variable and strrep? For example:

%% string i want to delete is "is_count_del=auto;"
delstrng=is_count_del_auto;
%%filetext is the name of the file from which is_count_del=auto; is to be deleted
r=strrep(filetext,'delstrng','');

I guess I am not using strrep correctly. How can the desired outcome be achieved?

Answers

If I understood you correctly, you could:

% open file to be filtered and output file
fin = fopen('file-to-be-filtered.txt');
fout = fopen('output-file.txt');

% for every line of a file-to-be-filtered ...
tline = fgets(fin);
while ischar(tline)
    % ... filter for all possible patterns        
    for delstring % -> delstring iterates over all patterns
        tline = strrep(tline, delstrng, '');
    end

    % save filtered line to file
    fprintf(fout, tline);

    % get next line
    tline = fgets(fin);
end

strrep can be applied on cell arrays, so this makes your work really easy:

% # Read input file
C = textread('input.txt', '%s', 'delimiter', '/n');

% # Remove target string
C = strrep(C, 'is_count_del=auto', '');

% # Write output file
fid = fopen('output.txt', 'w');
for ii = 1:numel(C)
    fprintf(fid, '%s/r/n', C{ii});
end
fclose(fid)