How to use regexprep() In MATLAB
The regexprep() function is used to replace text using regular expressions.
Syntax:
regexprep(str, expression, replace)
Example:
Matlab
% MATLAB code for regexprep method % for string space removal % Initializing a string String = 'G e e k s f o r G e e k s' ; % Replacing space with null using the % regexprep() function over the above string New_String = regexprep(String, '\s+' , '' ) |
Output:
New_String = w3wiki
How to remove space in a string in MATLAB?
In this article, we are going to discuss how to remove space from a string in MATLAB with the help of isspace(), find(), strrep(), and regexprep() functions.