MATLAB: How to find and replace tab or space characters

characterMATLABnonprintableregexprepreplacespacestrfindtab

I have a string, and I would like to find and replace the tabs and spaces with other characters. However, the STRFIND or STRREP functions don't seem to work.

Best Answer

The main method to replace tabs and spaces in MATLAB is to use regular expressions. Specifically, the REGEXPREP command is able to find tabs or spaces and replace them with any string. For example, to replace tabs with spaces in a string:
updatedString = regexprep(originalString, '\t', ' ');
Related Question