MATLAB: How to replace different variables with a single variable in a text file

regexprepreplacetext filetxt file

Hello everybody! I am not so used to editing and working with .txt files in MATLAB. I am looking for ways to replace multiple set of characters like '=' , '+', '-' with any single character like '%'. I guess I need to use regexprep for this purpose, but I am not able to figure it out for the .txt file. Any help will be appreciated. Thanks

Best Answer

Here is a simple example on how to use regexprep to replace '=','+','-' with '%'.
strIn = 'Please replace multiple set of characters like =, +, - with %';
strOut = regexprep(strIn,'[=+-]','%');
The result becomes:
>> strOut
strOut =
'Please replace multiple set of characters like %, %, % with %'